-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document params passing behavior in navigators #374
Comments
How about to get the params from component props and pass them as const TabNavigator = createBottomTabNavigator();
const Profile = (props) => (
<TabNavigator.Navigator>
<TabNavigator.Screen name='Account' component={Account} initialParams={props.route.params} />
<TabNavigator.Screen name='Settings' component={Settings} initialParams={props.route.params} />
</TabNavigator.Navigator>
);
` |
@arminghm Could you elaborate on how you would pass the props from the NavigationContainer seen below? I am trying to pass a specific item from a list dynamically to each tab. Similar to a task app where you can delve deeper into a specific task but I want the same data to be shared between the tabs. In this instance, would it be better to set up a ContextNavigator?
|
@martinodonnell perhaps you need a global state management like mobx or redux to achieve what you want, but if you want to pass params to the tab screens you can simply do what I mentioned here, and when you navigate to the tabNavigator with params ( |
@arminghm I read your post wrong and implemented it incorrectly. Left out the 's' in params. This is exactly what I wanted without having to use context. |
@martinodonnell oh, thanks 😉 |
react-navigation/react-navigation#5646
answer i give is:
the route that you navigate to receives the params, not any of its children.
this rfc could help: react-navigation/rfcs#68
more discussion on this here: react-navigation/rfcs#43
The text was updated successfully, but these errors were encountered: