React-native-router-flux: Props not passed from tab scene to sibling scene

Created on 28 Nov 2016  路  16Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux v3.36
  • react-native v0.37

Expected behaviour

object props are passed to scene like so

Actions.myScene({foo: {bar:"baz"}})

Actual behaviour

the props are not showing up in myScene

there is another issue that was closed #1390 for no reason. There were many breaking changes in RN36,37. Anyone else seeing their entire app break suddenly?

Most helpful comment

@DonnieWest it fixed it for me, thanks a bunch!

All 16 comments

Can you show an example?
I use RN0.37 and i don't have this problem.

<Scene key="worker" getSceneStyle={getSceneStyle} component={DrawerComponent} open={false}>
     <Scene key="workerTabs" getSceneStyle={getSceneStyle} tabBarStyle={tabBarStyle} tabs={true} >
           <Scene key='workerHome' component={ WorkerHome } title="Home" />
           <Scene key='workerShiftDetails' component={ WorkerShiftDetails } title="Home" hideTabBar={true} />

In WorkerHome navigating like so `Actions.WorkerShiftDetails({foo:"Bar"})

Mind you I am using both Drawer and Tabs and all of this is a subScene so perhaps one of those 3 things could be to blame?

If you don't use drawer or tabs, it works?

Hey @sarovin, I set 'tabs' to false and it works now, but why would sibling scenes not get the props. It actually used to back when I was using RN@35, [email protected]. Don't know what changed.

Sorry @ssomnoremac, i do not know...I can try to investigate when I have time.

Ran into this issue at work. Unsure if #1472 is the best solution, but it works for us

I tested passing value(props) on Example project.
I have no problem.
I pass the value like this.
{data:"Custom data", title:"Custom title", child: {data:"Child data"}}
In next page, I can get value from this.props.child.data.

@MechanicKim since I can't share my at work project, I'll try to get a minimal project setup that demonstrates the bug based on the example project.

The props only don't pass when the parent scene has tabs set and you are passing the props to a sibling like in the example from @ssomnoremac

Verified, I have the same problem on a personal project. I can solve the problem if I switch the scenes around, but it doesn't work as I would have expected.

Here props are undefined when passing from someTab to Modal via Actions.Modal({someProp: theProp}):

<Scene key="Scene" tabs={true}>
    <Scene key="someTab" component={SomeTab} title="SomeTab" icon={TabIcon}/>
    <Scene key="Modal" component={Modal} title="Modal" hideNavBar direction="vertical"/>
</Scene>

Here props come in as expected.

<Scene key="Scene" tabs={true}>
    <Scene key="someTab" component={SomeTab} title="Requests" icon={TabIcon}/>
</Scene>
<Scene key="Modal" component={Modal} title="Modal" hideNavBar direction="vertical"/>

Yes! I found the problem in 'Tab'.
When I move to tab page, I can transfer a data but I can't in 'Tab'.

@MechanicKim does #1472 fix it for you?

@DonnieWest it fixed it for me, thanks a bunch!

Since it seems like #1472 fixes this issue is there any chance we can get it merged in?

@sarovin @MechanicKim is there something I'm doing wrong that I can fix to get #1472 merged in?

@DonnieWest I have no objection about this fix.

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})

Was this page helpful?
0 / 5 - 0 ratings