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
关于react-redux中的Provider传值 #57
Comments
参考资料:redux必须用<Provider store={store} 这样传递全局的store吗?
这里的重点是Provider就是提供给connect(这里的意思应该是容器组件)store用的 |
|
参考资料: React实战-深入源码了解Redux用法之Provider
export default class Provider extends Component {
getChildContext() {
return { store: this.store }
}
constructor(props, context) {
super(props, context)
this.store = props.store
}
render() {
return Children.only(this.props.children)
}
}
constructor(props, context) {
super(props, context)
this.version = version
this.store = props.store || context.store
.......
} |
参考资料:React 实践心得:react-redux 之 connect 方法详解
这是的意思是只有容器组件才能访问到store中的数据,UI组件需要通过容器组件传递(通过connect方法中的mapStateToProps和mapDispatchToProps传递) |
问题:
The text was updated successfully, but these errors were encountered: