Reputation: 910
I have a Router of react-native-router-flux and configured among others two tabs:
<Scene key="page1" component={Page1} title="Page1" />
<Scene key="mytabs" tabs={true}>
<Scene key="tab1" component={Tab1}/>
<Scene key="tab2" component={Tab2}/>
</Scene>
I call my first tab and pass a prop like:
Actions.mytabs({id: 5});
This works fine and Tab1 component has access to that prop. But when clicking on the tab2 Navigation in my Tabbar, I don't have this id available anymore. How I can store it. In the state of the Router? How do I do this?
Thanks for your help
Upvotes: 0
Views: 506
Reputation: 11
Yes! I found the problem in 'Tab'. Tabs are 'wrapped' by default - i.e. all children are wrapped by Stack with own nav bar. You may disable wrapping by using wrap={false} for Tabs and check passing props again.
<Scene key="Scene" tabs={true} wrap={false}> <Scene key="someTab" component={SomeTab} title="SomeTab" icon={TabIcon}/> <Scene key="Modal" component={Modal} title="Modal" hideNavBar direction="vertical"/> </Scene>
Here props are find when passing from someTab to Modal via Actions.Modal({someProp: theProp})
Upvotes: 1
Reputation: 910
I think its not possible to keep this information somehow magically. I build a simple workaround by storing the id in redux and read it from there in each tab's component. Works great.
Upvotes: 0