-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
warning: Accessing child navigation state for a route is not safe and won't work correctly #8348
Copy link
Copy link
Closed
Labels
Description
Current Behavior
- Has a warning with navigation when I custom the navigationOptions
Expected Behavior
- I want it work correctly
How to reproduce
export const BottomNav = createCompatNavigatorFactory(createBottomTabNavigator)(
{
'takeout': { screen: ProfileScreen, navigationOptions:{
title: '外卖',
}},
'home':{screen: HomeScreen,navigationOptions:{
title: '我的',
}},
},
{
initialRouteName: 'takeout',
}
)
export const MainScreen = createCompatNavigatorFactory(createStackNavigator)(
{
'home': { screen: BottomNav, navigationOptions:({navigation})=> {
console.log('state',navigation.state)
let activeIndex = navigation.state.index
let routeName = activeIndex!=undefined? navigation.state.routes[activeIndex].name:'takeout'
return {
headerTitle: routeName,
}},
},
'我的':{ screen: HomeScreen}
},
{
initialRouteName: 'home',
}
)
Your Environment
| software | version |
|---|---|
| iOS or Android | ios&android |
| @react-navigation/native | 5.4.2 |
| @react-navigation/stack | 5.3.9 |
| react-native-gesture-handler | 1.6.1 |
| react-native-safe-area-context | |
| react-native-screens | |
| react-native | 0.62.2 |
| expo | no |
| node | 10.10.0 |
| npm or yarn | yarn |
Reactions are currently unavailable