I have got a Navigator that has to handle 4 different views, which should be on the same level. I am loading them in the InitialRouteStack and whenever I need one of them, I am calling jumpTo(route) and getting what I want.
However, when I change a value in one of the views, I do have a callback that updates the state of the given value where the Navigator is placed. I thought this would re-render the whole thing and update the props within the RouteStack.
This is not happening. I have also tried to run a forceUpdate() on the Navigator, but the props in each component are not updating. I keep having the values I passed when Navigator was rendered the first time.
Is there a way to solve this? I really don't want to use replace(route) because re-rendering each component every single time would be silly.
Edit I have looked at immediatelyResetRouteStack and replacedAtIndex, but they don't seem viable. The first one reset the whole thing, the second one replaces at Index, while, in theory, I should update the props passed to each component in the stack.
I had a similar question . There you can find possible solutions.
Eventually I used redux
to handle all the data flow, which solved the issue for me. There I connected every single smart component , at least the once included by a NavigatorIOS-Route, to the store. By that I completely bypass NavigatorIOS, together with passProps
.
Also there exists an issue for react-native about rerendering a component inside NavigatorIOS, when passProps changed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.