react-navigation / rfcs

RFCs for changes to React Navigation
Other
88 stars 16 forks source link

Navigator config to pass params down #68

Open ericvicenti opened 5 years ago

ericvicenti commented 5 years ago

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 commented 5 years ago

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