KadoBOT
KadoBOT

Reputation: 3124

Redux Provider not passing down Props/State

I've created a React App using create-react-app and added Redux to it. After adding <Provider store={store} /> only the component that I pass as the argument (the main component) on connectis receiving the props/state. Why do the nested components not receive them?

I will not paste the code here because I don't know what is causing the problem. Instead, here is the link to the entire App: https://github.com/KadoBOT/Box.es

Upvotes: 2

Views: 423

Answers (1)

The Reason
The Reason

Reputation: 7973

Currently you are connecting only MainPage or TemplatePage component, depends on condition. But you dont push props down. Here are couple ways how you can get it in your child components

  1. React.cloneElement

  2. using connect > connect(mapStateToProps, mapDispatchToProps)(ChildComponent)

  3. You can pass it explicitly from MainPage or TemplatePage component <ItemView {...this.props}/> ... <ItemSidebar {...this.props}/>

Thanks

Upvotes: 2

Related Questions