簡體   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