I have some navigators set up like this:
TabNavigator:
Tab1:
Tab2(id):
Screen1
Screen2
In short, I want to navigate to Screen1, passing an id
param to Tab2 and having it automatically pass that to Screen1. I know that you can manually pass the param to both Tab2 and Screen1 when calling the navigate method, but I’d rather not having to keep repeating that. Is this possible?
To elaborate more, I want to do this because the Context component that retrieves async data for Tab2’s screens (let’s call this ContextProvider1) are quite far up the tree (because it is used by other Tabs). When I navigate to Screen1, I pass id
to Tab1, and from there call a setId
that is provided by ContextProvider1. Whenever the id in ContextProvider1 changes and is not equal to the id of the data, I immediately set it to undefined so it isn’t displayed.
However, for some reason, it still takes a while for the the id to be updated and the old data still shows for about a second on Screen1. I don’t want the old data (which is often for a different id
) to be seen, however Screen1 has no way to access the current id unless I directly pass it to Screen1 in the navigation call, so Screen1 cannot itself figure out whether the data it has is the right set of data.
(To make the problem even weirder, if I pass the id to Screen1 when navigating to it, but don’t actually do anything with the id, then the problem of the old data showing disappears)