This is a React Native project that includes React Navigation and Redux. I have two scenes, the first one contains a ListView and a Button to add a new element to the list. This buttons navigates to a new Scene where I fill up a little form to create a new record that will appear on the list of the first scene.
这是一个React Native项目,包括React Navigation和Redux。我有两个场景,第一个包含ListView和一个Button,用于向列表中添加新元素。此按钮导航到一个新场景,我在其中填充一个小窗体以创建将出现在第一个场景列表中的新记录。
When hitting the save button and going back to the first scene (list view), mapStateToProps reflects the change but no other life cycle method is called (componentWillReceiveProps, shouldComponentUpdate, etc), none of them.
当点击保存按钮并返回第一个场景(列表视图)时,mapStateToProps反映了更改,但没有调用其他生命周期方法(componentWillReceiveProps,shouldComponentUpdate等),没有一个。
Now, both Scenes use connect from redux and I'm going back from Scene 2 to Scene 1 with the goBack() method from React Navigation. I'm wondering if redux get's "disconnected" from a view when showing a new one and how can I connect it back? Again, the mapStateToProps from the ListView scene is showing the data updated but it seems no props are being mapped.
现在,两个场景都使用了来自redux的连接,我将使用React Navigation中的goBack()方法从场景2返回到场景1。我想知道redux在显示一个新视图时是否与视图“断开连接”以及如何将其连接回来?同样,ListView场景中的mapStateToProps显示更新的数据,但似乎没有映射道具。
1 个解决方案
#1
0
It just seem the props don't refresh if the redux state value hasn't really change. Copying the list array before modifying it and then assigning it to the payload seems to fix the issue.
如果redux状态值没有真正改变,那么道具似乎不会刷新。在修改列表数组之前复制它,然后将其分配给有效负载似乎可以解决问题。
#1
0
It just seem the props don't refresh if the redux state value hasn't really change. Copying the list array before modifying it and then assigning it to the payload seems to fix the issue.
如果redux状态值没有真正改变,那么道具似乎不会刷新。在修改列表数组之前复制它,然后将其分配给有效负载似乎可以解决问题。