切换导航器引发错误 "undefined is not an object ( 'this.props')"
switch navigator throws an error "undefined is not an object ( 'this.props')"
我不知道在这里做什么我已经尝试过堆栈导航器也有同样的问题 props ;/
进入画面
...
export default function App(props) {
return (
<View style={{flex:1 , justifyContent:'center', alignItems:'center'}}>
<TouchableOpacity onPress={()=>{
console.log(props)
this.props.navigation.navigate('Home')
//this.props.navigation.dispatch(SwitchActions.jumpTo('Home'))
} } >
<Text>switch test</Text>
</TouchableOpacity>
</View>
);
}...
导航
...
const SwitchNavigation = createStackNavigator({
Enter:{screen : EnterScreen},
Home:{ screen :HomeScreen}
})...
export default createAppContainer(SwitchNavigation);
APP
...
export default function App(props) {
return (
<NavigaitonScreens />
);
}...
与导航无关
功能组件中没有 this
...
像props.navigation.navigate('Home')
一样直接访问props
我不知道在这里做什么我已经尝试过堆栈导航器也有同样的问题 props ;/
进入画面
...
export default function App(props) {
return (
<View style={{flex:1 , justifyContent:'center', alignItems:'center'}}>
<TouchableOpacity onPress={()=>{
console.log(props)
this.props.navigation.navigate('Home')
//this.props.navigation.dispatch(SwitchActions.jumpTo('Home'))
} } >
<Text>switch test</Text>
</TouchableOpacity>
</View>
);
}...
导航
...
const SwitchNavigation = createStackNavigator({
Enter:{screen : EnterScreen},
Home:{ screen :HomeScreen}
})...
export default createAppContainer(SwitchNavigation);
APP
...
export default function App(props) {
return (
<NavigaitonScreens />
);
}...
与导航无关
功能组件中没有 this
...
像props.navigation.navigate('Home')
props