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

How to access child <Scene> props from parent's tabBarComponent? #3044

Closed
rayj10 opened this issue May 21, 2018 · 3 comments
Closed

How to access child <Scene> props from parent's tabBarComponent? #3044

rayj10 opened this issue May 21, 2018 · 3 comments

Comments

@rayj10
Copy link

rayj10 commented May 21, 2018

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.28

Sorry for the noob question, but if I have the following structure:

<Scene tabs={true} tabBarComponent={()=><ScrollableTabBar items={["Approval", "My Request", " DO Customer", "My Confirm", "View Request"]}/>} tabBarPosition='top' lazy={true}>
       <Scene key="Home" hideNavBar component={Home} title={"Home"} name='Home'/>
</Scene>

How can I access child scene's (in this case the scene with key='Home') props like title, name, or key from within ScrollableTabBar?

Thanks in advance for the pointers! :)

@rayj10 rayj10 changed the title How to access How to access child props from parent's tabBarComponent May 21, 2018
@rayj10 rayj10 changed the title How to access child props from parent's tabBarComponent How to access child props from parent's tabBarComponent? May 21, 2018
@rayj10 rayj10 changed the title How to access child props from parent's tabBarComponent? How to access child <Scene> props from parent's tabBarComponent? May 21, 2018
@daviscabral
Copy link
Collaborator

@rayj10 are not you able to access it from this.props.title?

@rayj10
Copy link
Author

rayj10 commented May 22, 2018

@daviscabral not from within ScrollableTabBar... besides it would be weird if say Home is not the only child of the scene with ScrollableTabBar wouldn't it?

I have changed my structure anyhow because I found a better way of achieving what I wanted to. But just for future reference I would still like to know how can I access the array of children and their props from a component loaded onto parent scene i.e. ScrollableTabBar?

I know that usually it's available via this.props.children but thats if I have something like:

<ScrollableTabBar>
            <Child1>
            <Child2>

but if I have this:

<Scene tabBarComponent={ScrollableTabBar}>
            <Child1>
            <Child2>

this.props.children is returning undefined from within ScrollableTabBar

@aksonov
Copy link
Owner

aksonov commented Jun 6, 2018

RNRF doesn't give you access to the child components. You may check navigationState prop to get your navigation state.

@aksonov aksonov closed this as completed Jun 6, 2018
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

3 participants