I'm trying to understand the connect method of react-redux, and the functions it takes as parameters.(我试图理解react-redux的连接方法,以及它作为参数所采用的函数。)
In particular mapStateToProps()
.(特别是mapStateToProps()
。)
The way I understand it, the return value of mapStateToProps
will be an object derived from state (as it lives in the store), whose keys will be passed to your target component (the component connect is applied to) as props.(我理解它的方式, mapStateToProps
的返回值将是一个从状态派生的对象(因为它存在于商店中),其键将作为道具传递给目标组件(应用组件连接)。)
This means that the state as consumed by your target component can have a wildly different structure from the state as it is stored on your store.(这意味着目标组件所使用的状态与存储在商店中的状态可能具有完全不同的结构。)
Q: Is this OK?(问:这样可以吗?)
Q: Is this expected?(问:这是预期的吗?)
Q: Is this an anti-pattern?(问:这是反模式吗?)
ask by Pablo Barría Urenda translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…