繁体   English   中英

反应重组通行证道具

[英]React recompose pass props

例如,我们有一个容器<ContainerName data=someData>并传递了一些props data

在此容器中,我们使用recompose并具有以下代码:

const enhance = compose(
      withProps({
        statuses: ['ordered', 'received'],
      }),
      withProps(
        // how do I pass props from this container to component ?
      ),
      withState('error', 'setError', false),
      withState('successAdded', 'setSuccessAdded', false),
      withState('loading', 'setLoading', false),
      withState('confirmModal', 'setConfirmModal', false),
...
export default enhance(ComponentForm);

我们如何将属于此容器的道具传递给组件?

组件无需声明将通过重组HOC接收到的所有道具就可以使用它(除非您通过mapProps明确在compose函数中省略了道具)。

像使用常规组件一样传递数据,并让您的子组件像使用任何常规道具一样使用它

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM