
react
文章平均质量分 70
姜无忧
莫问前程凶吉,但求落幕无悔
展开
-
redux、react-redux、redux-thunk、redux-saga对比
reduxredux工作流程示意图actions函数形式,返回 action 对象,通常具有type属性。负责指令的生成,页面通过 store.dispatch(action) 向 store 发送数据修改的请求。reducers一个纯函数,接收两个参数 (previousState, action) 第一个表示修改之前的 state 的值,action 是上一步页面通过 store.dispatch(action) 向 store 传递的 action。reducers 通过 ac原创 2022-05-07 13:45:50 · 987 阅读 · 1 评论 -
React 父子组件方法调用及通信
父=>子父组件向子组件传递数据:通过传 props 的方式,向子组件进行传递数据父组件调用子组件的方法:可以给子组件,通过ref起个名字,然后在父组件的点击事件中,通过this.refs.子组件的名字.子组件的方法来实现子=>父子组件调用父组件的方法(传递参数):通过调用父组件的方法时,通过callback回调传递数据。this.props.父组件的方法(传递的数据)...原创 2019-08-27 17:39:05 · 2581 阅读 · 0 评论 -
常用的react生命周期的简单总结
常用的生命周期图示:挂载阶段:constructor => render => componentDidMount => 结束更新阶段:render =>componentDidUpdate => 结束卸载阶段:componentWillUnmount => 结束constructor构造函数用于以下两种情况: 通过给 this.s...原创 2019-08-27 16:58:53 · 1386 阅读 · 1 评论 -
redux+react-redux基本介绍+使用案例(二)
1.创建storesrc/redux/store/index.jsimport { createStore } from 'redux';import reducers from '../reducers';const store = createStore(reducers);export default store;2.创建actionTypessrc/redux/...原创 2019-07-31 23:11:55 · 219 阅读 · 0 评论 -
redux+react-redux基本介绍+使用案例(一)
其实,redux和react并没有半毛钱的关系,redux甚至可以和jq一起用。 react-redux才是react的用于便捷操作redux的第三方插件。1.创建项目create-react-app redux-demo2.安装reduxnpm install redux --S3.安装react-reduxnpm install react-redux --S...原创 2019-07-31 22:57:56 · 588 阅读 · 0 评论 -
react安装即搭建项目
首先,我们需要安装node 和 npm然后:npm install -g create-react-app(cnpm install -g create-react-app)create-react-app my-appcd my-app/npm startmac中,npm install -g create-react-app会出现权限报错。我们可以 sudonpm in...原创 2019-03-30 21:43:04 · 134 阅读 · 0 评论