Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redux与react-redux的使用总结 #66

Open
gdutwyg opened this issue Jul 23, 2019 · 0 comments
Open

redux与react-redux的使用总结 #66

gdutwyg opened this issue Jul 23, 2019 · 0 comments
Labels

Comments

@gdutwyg
Copy link
Owner

gdutwyg commented Jul 23, 2019

一个简单的react-redux的项目一般都包括reducers, action , component , container

  • reducers 定义state的变化后的返回,还有初始值。
  • action 定义的是改变state所需要的数据的函数,它不参与如何改变state,仅仅是供reducers调用。
  • component 定义的是纯函数/组件,不涉及到redux;
  • container 定义的是和redux的交互,定义mapStateToPropsmapDispatchToProps,引入react-redux的connect,component,将mapStateToProps里的state,mapDispatchToProps的函数通过props传给component

reducers 定义好后,需要在根组件下使用redux提供的createStore调用,然后通过react-redux提供的provider把createStore返回的store传给子组件。

以上只是简单的描述,具体的代码可以查看这个demo,可以会更深刻一点。

@gdutwyg gdutwyg changed the title react-redux redux与react-redux的使用总结 Jul 23, 2019
@gdutwyg gdutwyg added the react label Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant