question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Passing props to nested tab scenes

See original GitHub issue

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta26
  • react-native v0.50.3

Expected behaviour

When navigated from a login screen to a nested scene with tabs, all children tab scenes should have a prop passed to the parent scene by Actions

Actual behaviour

The prop cannot be passed to the parent scene. It will work as expected if I pass it to a child scene using Actions, but I want the prop to be available to all children tab scenes

Steps to reproduce

For non-obvious bugs, please fork this component, modify Example project to reproduce your issue and include link here.

  1. Sign in with any username and password
  2. navigate to create trip tap
  3. hit create trip, alert(this.props.user_id) is undefined

My declarations of the Scenes hierarchy

         <Scene key = "main" tabs = {true} hideNavBar = {true} >
            <Scene key = "feedTab" hideNavBar = {true} title = " " iconName = "Feed" icon = {TabIcon} >
              <Scene key ="home" component = {Feed} title = "Home"/>
            </Scene>

            <Scene key = "createTripTab" hideNavBar = {true} title = " " iconName = "Create Trip" icon = {TabIcon}>
              <Scene key = "createTrip" component = {CreateTrip} title = "Create Trip" />
            </Scene>

            <Scene key = "findHostTab" hideNavBar = {true} title = " " iconName = "Find Host" icon = {TabIcon} >
              <Scene key = "findHost" component = {FindHost} title = "Find Host" />
            </Scene>

            <Scene key = "profileTab" hideNavBar = {true} title = " " iconName = "Profile" icon = {TabIcon} >
              <Scene key = "profile" component = {Profile} title = "Profile" />
            </Scene>

          </Scene>

Actions.main({user_id: json.user_id}) doesnt work while Actions.createTripTab({user_id: json.user_id}) works

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
anuj002commented, Jul 11, 2019

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

5reactions
aksonovcommented, Aug 8, 2018

Please check Example project and TabView.js with Actions.tab_5_1({ data: 'test!' })

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Passing Props through Nested Navigators
I would ideally like to pass props (the data object) to both the Info and Chapter URIs under the tab navigator. I assume...
Read more >
Nested Tabs in ReactJS - GeeksforGeeks
In this article, we will see how to create nested tabs using React Tabs which is an accessible and easy tab component for...
Read more >
React router v6 pass props on Link click - YouTube
In this video, I am walking through React Router v6, mainly using params, passing value from params, and showing the values.
Read more >
Learn how to handle nested routes and nested content using ...
React router pass the match props, we retrieve the user info using the userName value from our data. Showing nested routes as tab...
Read more >
Navigation prop reference
It's important to highlight the navigation prop is not passed in to all components; ... jumpTo - go to a specific screen in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found