2017-03-17 71 views
1

例如,我們有一個容器<ContainerName data=someData>並通過一些道具數據React重新組合通道道具

在這個容器中,我們使用重新構圖並有下面的代碼:

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); 

我們如何通過屬於該容器,以我們的組件的道具?

回答

4

組件不需要通過重構HOC來聲明它將接收的所有道具,以便能夠使用它(除非您通過mapProps明確地忽略了撰寫功能中的道具)。

按照正常組件那樣傳遞數據,讓您的子組件使用它,就像任何普通支柱一樣