react-native - 切换导航器抛出错误“未定义不是对象('this.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);
应用程序
...
export default function App(props) {
return (
<NavigaitonScreens />
);
}...
解决方案
它与导航无关。
this
功能组件中没有...
直接访问props
喜欢props.navigation.navigate('Home')
推荐阅读
- java - 如何在Android上将POST请求加载到带有标题和正文的Webview
- cardano - 可以创建私人卡尔达诺网络吗?
- angular - 如何为此端点结果制作域模型?
- sql - 带有运算符的 PostgreSQL CASE WHEN 返回空行
- php - 使用php在shopify中添加脚本标签
- css - 我需要帮助在引导程序 4 中订购列
- javascript - 在 this.props.dispatch(push(path)) 上没有发生 React 转换
- javascript - 替代粘性位置?
- azure-devops - 为什么我在 Azure DevOps Build Pipeline 中的测试会运行两次?
- google-cloud-firestore - 是否可以在 Airflow 中使用 datastore_export_operator 导出 Firestore 备份?