小编Ali*_*eza的帖子

如何在常量中使用反应导航?

我使用 const 来显示组件。现在,当我对 const 中的按钮使用反应导航时,我看到了这个错误:未定义不是一个对象(评估 '_this.props.navigation.navigate')

我尝试将 navigation={this.props.navigation} 添加到按钮以允许导航,但没有奏效。

const WomenTab = () => (
    <View>
      <Button onPress={() => {
                        this.props.navigation.dispatch(StackActions.reset({
                          index: 0,
                          actions: [
                            NavigationActions.navigate({ routeName: 'Wallet' })
                          ],
                        }))
                      }}>
          <Text>Click</Text>
      </Button>
    <View>
);
Run Code Online (Sandbox Code Playgroud)

库链接:http : //github.com/react-native-community/react-native-tab-view

reactjs react-native react-native-navigation react-navigation

2
推荐指数
1
解决办法
755
查看次数