当应用程序状态更改时,子组件(MapLeftNav,Map)不会重新呈现 . 它有一个父组件(MapView)和几个兄弟 .
假设:
1)应用程序状态正在改变并被Redux跟踪
-
该操作显示在Redux Dev工具中,包含更新的字段;
-
我正在父组件(MapView)中记录vehiclesState,它们正在改变;
2)我的减速器不只是变异状态(gist here)
-Redux开发工具和Parent( connect
ed compoent)很乐意接受这些变化
case NEW_MESSAGES:
return reduceVehicleMessagesToVehicles(state, action.payload)
然后该函数返回:
return {
vehicles: updatedVehicles,
traces: updatedTraces,
vehicleMessagesLoading: messagesLoading,
}
3)父组件(MapView, gist here)正在接收新的道具但不接收子MapLeftNav
-
我在console.log中使用了props,并在Parent组件中进行了更改
-
我写了一个假的
componentWillReceiveProps (nextProps) {console.log(nextProps)}
,该函数永远不会被子MapLeftNav组件触发 .
<MapLeftNav
mapState={mainMap}
push={push}
vehicles={vehiclesState.vehicles}
updateCounter={vehiclesState.updateCounter}
/>
4)MapLeftNav组件,根据要求:https://gist.github.com/thomasgwatson/36d8f6dbd64b0f6425b4beef56075acd
使用React,Redux,React-Redux绑定,react-redux开发工具,材料UI等 . 我使用React大约18个月而Redux使用了两个月 .
当我直接 connect
redux到子组件时,一切正常 . 当我将它们传递给父组件并尝试将应用程序状态作为道具传递时,子组件似乎不会记录状态的更改 .
据我了解,我不应该 connect
我的所有组件都能够使用redux商店中保存的应用程序状态!关于问题的可能来源的任何提示?