Skip to content
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

Navigator config to pass params down #68

Open
ericvicenti opened this issue Nov 17, 2018 · 1 comment
Open

Navigator config to pass params down #68

ericvicenti opened this issue Nov 17, 2018 · 1 comment

Comments

@ericvicenti
Copy link
Contributor

I was chatting with @geirman and I think we may want to add passParams to the navigator config:

createStackNavigator({
  Main,
  MyTabs: createTabNavigator({
    A,
    B,
  }, { passParams: [ 'foo' ] })
})

Say you go from Main .navigate('MyTabs', {foo: 'bar'}).. Thanks to the proposed passParams, screens A and B would have access to the "foo" param.

I'll try to get to this in the coming weeks. Let me know if anybody wants to take a stab at implementing this.. I'd be happy to support you.

cc @brentvatne

@geirman
Copy link

geirman commented Nov 17, 2018

For more info (if needed), this came about because I needed to pass params down from a tab navigator to a child stack navigator. Here's a link to the stack overflow, which has a link to a snack demo. Thanks for the work around, @ericvicenti !

https://stackoverflow.com/questions/53311593/passing-state-in-react-navigation-from-tabsnavigation-to-child-stacknavigation/53344281#53344281

richeterre added a commit to richeterre/jumu-app that referenced this issue Jul 30, 2019
Instead of passing the selected contest as a nav param to the nested navigation structure (tab + stack navigators), which is tricky because params don't propagate to child navigators (see react-navigation/rfcs#43 and react-navigation/rfcs#68), we wrap the navigator structure with a ContestNavigator that receives the current contest as a prop, and passes it forward to its navigation screens as a param. The RootView component tracks the current contest and renders either a ContestNavigator or (if no contest selected) a contest picker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants