Pass state to recursively nested component in React/Redux

大憨熊 提交于 2019-11-30 04:03:41

Well, if I understand it right, you want these Material components to get it's data from the redux store.
If that's what you want to achieve you need to provide access to the redux's store to each one of the Material. Basically you need to wrap all of them with the connect HOC.
Example:

const MaterialContainer = connect(mapStateToProps)(Material);

And inside the renderChild function you would use this MaterialContainer.

renderChild = (id) => (
  <MaterialContainer key={childId} id={childId} />
)

You can see it working here https://jsbin.com/taquke/edit?js,output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!