Cannot navigate to route from within navigation stack.
up vote
0
down vote
favorite
I have one file with my whole navigation stack. In my navigation header I have a menu and I want to open a Drawer. Now In this example I get the error: Cannot read property 'navigation' of undefined
My AppNavigation file:
import React from 'react';
import Text from 'react-native';
import createStackNavigator, createDrawerNavigator from 'react-navigation';
import Login from '../components/Login';
import Dashboard from '../components/Dashboard';
import NewNotification from '../components/NewNotification';
const GuestStack = createStackNavigator(
loginScreen: screen: Login ,
,
headerMode: 'float',
headerLayoutPreset: 'center',
navigationOptions:
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welcome',
headerTintColor: 'black',
,
,
);
const LoggedinStack = createDrawerNavigator(
dashboard: screen: Dashboard ,
newNotifciation: screen: NewNotification ,
);
const LoggedinNavigation = createStackNavigator(
LoggedinStack: screen: LoggedinStack ,
,
headerMode: 'float',
navigationOptions:
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welkom!',
headerTintColor: 'black',
headerLeft: <Text onPress = () =>
this.props.navigation.openDrawer('dashboard')
// navigation.openDrawer('dashboard')
>Menu</Text>,
,
,
);
const VveNavigator = createStackNavigator(
guestStack:
screen: GuestStack,
,
loggedinStack:
screen: LoggedinNavigation,
,
,
headerMode: 'none',
initialRouteName: 'guestStack',
,
);
export default AppNavigator;
The problem seems to be over here:
headerLeft: <Text onPress = () =>
this.props.navigation.openDrawer('dashboard')
// navigation.openDrawer('dashboard')
>Menu</Text>,
And then in my App.js I have
export default class App extends React.Component
render()
return (
<APPNavigator />
);
Version of react navigation is 2.18.1
Thanks
react-native react-navigation react-navigation-drawer
add a comment |
up vote
0
down vote
favorite
I have one file with my whole navigation stack. In my navigation header I have a menu and I want to open a Drawer. Now In this example I get the error: Cannot read property 'navigation' of undefined
My AppNavigation file:
import React from 'react';
import Text from 'react-native';
import createStackNavigator, createDrawerNavigator from 'react-navigation';
import Login from '../components/Login';
import Dashboard from '../components/Dashboard';
import NewNotification from '../components/NewNotification';
const GuestStack = createStackNavigator(
loginScreen: screen: Login ,
,
headerMode: 'float',
headerLayoutPreset: 'center',
navigationOptions:
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welcome',
headerTintColor: 'black',
,
,
);
const LoggedinStack = createDrawerNavigator(
dashboard: screen: Dashboard ,
newNotifciation: screen: NewNotification ,
);
const LoggedinNavigation = createStackNavigator(
LoggedinStack: screen: LoggedinStack ,
,
headerMode: 'float',
navigationOptions:
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welkom!',
headerTintColor: 'black',
headerLeft: <Text onPress = () =>
this.props.navigation.openDrawer('dashboard')
// navigation.openDrawer('dashboard')
>Menu</Text>,
,
,
);
const VveNavigator = createStackNavigator(
guestStack:
screen: GuestStack,
,
loggedinStack:
screen: LoggedinNavigation,
,
,
headerMode: 'none',
initialRouteName: 'guestStack',
,
);
export default AppNavigator;
The problem seems to be over here:
headerLeft: <Text onPress = () =>
this.props.navigation.openDrawer('dashboard')
// navigation.openDrawer('dashboard')
>Menu</Text>,
And then in my App.js I have
export default class App extends React.Component
render()
return (
<APPNavigator />
);
Version of react navigation is 2.18.1
Thanks
react-native react-navigation react-navigation-drawer
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have one file with my whole navigation stack. In my navigation header I have a menu and I want to open a Drawer. Now In this example I get the error: Cannot read property 'navigation' of undefined
My AppNavigation file:
import React from 'react';
import Text from 'react-native';
import createStackNavigator, createDrawerNavigator from 'react-navigation';
import Login from '../components/Login';
import Dashboard from '../components/Dashboard';
import NewNotification from '../components/NewNotification';
const GuestStack = createStackNavigator(
loginScreen: screen: Login ,
,
headerMode: 'float',
headerLayoutPreset: 'center',
navigationOptions:
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welcome',
headerTintColor: 'black',
,
,
);
const LoggedinStack = createDrawerNavigator(
dashboard: screen: Dashboard ,
newNotifciation: screen: NewNotification ,
);
const LoggedinNavigation = createStackNavigator(
LoggedinStack: screen: LoggedinStack ,
,
headerMode: 'float',
navigationOptions:
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welkom!',
headerTintColor: 'black',
headerLeft: <Text onPress = () =>
this.props.navigation.openDrawer('dashboard')
// navigation.openDrawer('dashboard')
>Menu</Text>,
,
,
);
const VveNavigator = createStackNavigator(
guestStack:
screen: GuestStack,
,
loggedinStack:
screen: LoggedinNavigation,
,
,
headerMode: 'none',
initialRouteName: 'guestStack',
,
);
export default AppNavigator;
The problem seems to be over here:
headerLeft: <Text onPress = () =>
this.props.navigation.openDrawer('dashboard')
// navigation.openDrawer('dashboard')
>Menu</Text>,
And then in my App.js I have
export default class App extends React.Component
render()
return (
<APPNavigator />
);
Version of react navigation is 2.18.1
Thanks
react-native react-navigation react-navigation-drawer
I have one file with my whole navigation stack. In my navigation header I have a menu and I want to open a Drawer. Now In this example I get the error: Cannot read property 'navigation' of undefined
My AppNavigation file:
import React from 'react';
import Text from 'react-native';
import createStackNavigator, createDrawerNavigator from 'react-navigation';
import Login from '../components/Login';
import Dashboard from '../components/Dashboard';
import NewNotification from '../components/NewNotification';
const GuestStack = createStackNavigator(
loginScreen: screen: Login ,
,
headerMode: 'float',
headerLayoutPreset: 'center',
navigationOptions:
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welcome',
headerTintColor: 'black',
,
,
);
const LoggedinStack = createDrawerNavigator(
dashboard: screen: Dashboard ,
newNotifciation: screen: NewNotification ,
);
const LoggedinNavigation = createStackNavigator(
LoggedinStack: screen: LoggedinStack ,
,
headerMode: 'float',
navigationOptions:
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welkom!',
headerTintColor: 'black',
headerLeft: <Text onPress = () =>
this.props.navigation.openDrawer('dashboard')
// navigation.openDrawer('dashboard')
>Menu</Text>,
,
,
);
const VveNavigator = createStackNavigator(
guestStack:
screen: GuestStack,
,
loggedinStack:
screen: LoggedinNavigation,
,
,
headerMode: 'none',
initialRouteName: 'guestStack',
,
);
export default AppNavigator;
The problem seems to be over here:
headerLeft: <Text onPress = () =>
this.props.navigation.openDrawer('dashboard')
// navigation.openDrawer('dashboard')
>Menu</Text>,
And then in my App.js I have
export default class App extends React.Component
render()
return (
<APPNavigator />
);
Version of react navigation is 2.18.1
Thanks
react-native react-navigation react-navigation-drawer
react-native react-navigation react-navigation-drawer
asked Nov 9 at 9:47
sanders
4,3592369111
4,3592369111
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
headerLeft
doesn't receive navigation
prop (check the source code). So if you'd like to use a navigation prop on press, you should consider to refactor your stack navigator config:
const LoggedinNavigation = createStackNavigator(
LoggedinStack: screen: LoggedinStack ,
,
headerMode: 'float',
navigationOptions: ( navigation ) => ( // here you get the navigation
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welkom!',
headerTintColor: 'black',
headerLeft: (
<Text
onPress=() =>
navigation.openDrawer()
>
Menu
</Text>
),
),
,
);
Check this issue for more options.
Thanks for your comment. With this the error goes away. But the drawer does not open.
– sanders
Nov 9 at 10:19
1
I solved it myself by doing this: navigation.openDrawer(); Thanks for your help
– sanders
Nov 9 at 10:23
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
headerLeft
doesn't receive navigation
prop (check the source code). So if you'd like to use a navigation prop on press, you should consider to refactor your stack navigator config:
const LoggedinNavigation = createStackNavigator(
LoggedinStack: screen: LoggedinStack ,
,
headerMode: 'float',
navigationOptions: ( navigation ) => ( // here you get the navigation
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welkom!',
headerTintColor: 'black',
headerLeft: (
<Text
onPress=() =>
navigation.openDrawer()
>
Menu
</Text>
),
),
,
);
Check this issue for more options.
Thanks for your comment. With this the error goes away. But the drawer does not open.
– sanders
Nov 9 at 10:19
1
I solved it myself by doing this: navigation.openDrawer(); Thanks for your help
– sanders
Nov 9 at 10:23
add a comment |
up vote
1
down vote
accepted
headerLeft
doesn't receive navigation
prop (check the source code). So if you'd like to use a navigation prop on press, you should consider to refactor your stack navigator config:
const LoggedinNavigation = createStackNavigator(
LoggedinStack: screen: LoggedinStack ,
,
headerMode: 'float',
navigationOptions: ( navigation ) => ( // here you get the navigation
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welkom!',
headerTintColor: 'black',
headerLeft: (
<Text
onPress=() =>
navigation.openDrawer()
>
Menu
</Text>
),
),
,
);
Check this issue for more options.
Thanks for your comment. With this the error goes away. But the drawer does not open.
– sanders
Nov 9 at 10:19
1
I solved it myself by doing this: navigation.openDrawer(); Thanks for your help
– sanders
Nov 9 at 10:23
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
headerLeft
doesn't receive navigation
prop (check the source code). So if you'd like to use a navigation prop on press, you should consider to refactor your stack navigator config:
const LoggedinNavigation = createStackNavigator(
LoggedinStack: screen: LoggedinStack ,
,
headerMode: 'float',
navigationOptions: ( navigation ) => ( // here you get the navigation
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welkom!',
headerTintColor: 'black',
headerLeft: (
<Text
onPress=() =>
navigation.openDrawer()
>
Menu
</Text>
),
),
,
);
Check this issue for more options.
headerLeft
doesn't receive navigation
prop (check the source code). So if you'd like to use a navigation prop on press, you should consider to refactor your stack navigator config:
const LoggedinNavigation = createStackNavigator(
LoggedinStack: screen: LoggedinStack ,
,
headerMode: 'float',
navigationOptions: ( navigation ) => ( // here you get the navigation
headerStyle: backgroundColor: '#61b1cd' ,
title: 'Welkom!',
headerTintColor: 'black',
headerLeft: (
<Text
onPress=() =>
navigation.openDrawer()
>
Menu
</Text>
),
),
,
);
Check this issue for more options.
edited Nov 9 at 12:14
answered Nov 9 at 10:05
Georgiy T.
35449
35449
Thanks for your comment. With this the error goes away. But the drawer does not open.
– sanders
Nov 9 at 10:19
1
I solved it myself by doing this: navigation.openDrawer(); Thanks for your help
– sanders
Nov 9 at 10:23
add a comment |
Thanks for your comment. With this the error goes away. But the drawer does not open.
– sanders
Nov 9 at 10:19
1
I solved it myself by doing this: navigation.openDrawer(); Thanks for your help
– sanders
Nov 9 at 10:23
Thanks for your comment. With this the error goes away. But the drawer does not open.
– sanders
Nov 9 at 10:19
Thanks for your comment. With this the error goes away. But the drawer does not open.
– sanders
Nov 9 at 10:19
1
1
I solved it myself by doing this: navigation.openDrawer(); Thanks for your help
– sanders
Nov 9 at 10:23
I solved it myself by doing this: navigation.openDrawer(); Thanks for your help
– sanders
Nov 9 at 10:23
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53223333%2fcannot-navigate-to-route-from-within-navigation-stack%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown