Redux Provider Does Not Skip Props / Status

I created a React application using the create-react-app and added Redux to it. After adding <Provider store={store} />only the component that I pass as an argument (the main component) to connectgets the props / state. Why don't nested components get them?

I will not embed code here because I do not know what causes the problem. Instead, here is a link to the entire application: https://github.com/KadoBOT/Box.es

+2
source share
1 answer

Currently, you are connectonly a component MainPage or TemplatePage, state dependent. But you do not click the props. Here are some ways you can get it in your child components.

  • React.cloneElement

  • using connect connect(mapStateToProps, mapDispatchToProps)(ChildComponent)

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

thank

+2
source

Source: https://habr.com/ru/post/1663608/


All Articles