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

this.props.navigationState is undefined #2000

Closed
xahon opened this issue Jul 10, 2017 · 18 comments
Closed

this.props.navigationState is undefined #2000

xahon opened this issue Jul 10, 2017 · 18 comments

Comments

@xahon
Copy link

xahon commented Jul 10, 2017

https://github.com/aksonov/react-native-router-flux/blob/master/docs/OTHER_INFO.md#drawer-side-menu-integration

<Scene
  key='main'
  component={ MainScreen }
  hideNavBar={ true }
  type='reset'
  tabs={ true }
>
  <Scene
    key='contacts'
    component={ ContactsView }
    initial={ true }
  />
  <Scene
    key='projects'
    component={ ProjectsView }
  />
</Scene>

Inside MainScreen#render() this.props.navigationState is undefined, why?

rnrf: 4.0.0-beta.6

@aksonov
Copy link
Owner

aksonov commented Jul 10, 2017

You may use props.navigation.state instead. I will add navigationState for backward compartibility soon.

@xahon
Copy link
Author

xahon commented Jul 10, 2017

In this path the field children is missing

@aksonov
Copy link
Owner

aksonov commented Jul 10, 2017

Do you mean this.props.navigationState.children? Yes, it is replaced to this.props.navigation.routes. Will add it to 'Breaking changes'.

@xahon
Copy link
Author

xahon commented Jul 10, 2017

Yes, i mean that but there is no routes field
image

@aksonov
Copy link
Owner

aksonov commented Jul 10, 2017

Could you check navigation.routes ?

@xahon
Copy link
Author

xahon commented Jul 10, 2017

image

@aksonov
Copy link
Owner

aksonov commented Jul 10, 2017

It is weird, let me check.

@aksonov
Copy link
Owner

aksonov commented Jul 10, 2017

There is no 'children' because RNRF Router interpret 'main' as leaf (because 'component' is defined). So V4 accepts children OR component prop.

If you want to use custom tab container you have to use custom Navigator and pass it as navigator prop:
https://reactnavigation.org/docs/navigators/custom

@aksonov aksonov closed this as completed Jul 10, 2017
@aksonov aksonov reopened this Jul 10, 2017
@aksonov aksonov closed this as completed Jul 10, 2017
@ghost
Copy link

ghost commented Nov 27, 2017

To be honest, I am not sure what the last comment means.

Can you elaborate more @aksonov ?

@amang8662
Copy link

Yeah, even I don't understand the meaning behind the last comment @aksonov . Can you please explain it?

@aksonov
Copy link
Owner

aksonov commented Feb 6, 2018

Original code was taken from v3 and applied to v4 that is wrong. Starting from v4 'container' scenes (like tabs, stack, etc.) cannot have 'component' prop but 'contentComponent' instead

@amang8662
Copy link

amang8662 commented Feb 7, 2018

I am trying to implement react-native-drawer in rnrf and using this.props.navigation.state instead of this.props.navigationState but facing following error.
capture1

the props i am gettting are

capture

My Code is:
NavigationDrawer.js
capture3

Routes.js

capture2

What should i pass to DefaultRenderer component to make it work?

@Blapi
Copy link
Collaborator

Blapi commented Feb 7, 2018

Not really sure about what is your issue here but as you can see in your logs, you have no children defined.

As a workaround, you may use Actions._state where routes is defined :

screenshot from 2018-02-07 13-32-40

@amang8662
Copy link

amang8662 commented Feb 7, 2018

I want to know about the parameters to be passed to navigationState & onNavigate props of DefaultRenderer. Anything other than children[0] which i pass to navigationState returns error like this.

capture6

Data i'm getting from Actions._state in NavigationDrawer.js

capture4

@temadev
Copy link

temadev commented Feb 9, 2018

Stuck on the same place. I think we have to extend somehow children[0] by data from Actions._state, but have no idea how can we do that trick. Looks like we still need some kind of DefaultRenderer component to render it together

@Dgs-asohail4
Copy link

Strange this is still not fixed

@ghost
Copy link

ghost commented Dec 3, 2018

@Dgs-asohail4 RNRF has now its own drawer.
react-native-drawer can be removed and simple RNRF's drawer can be used.

It's easy to use and manage. You might need to refactor your routing file though.

And this.props.navigationState is now available as this.props.navigation.state.

@burhanuddin-emaster
Copy link

I have updated with RN-v0.59.8 and I am also not getting children key, can you please tell me how we can achieve that ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants