Can't find variable: navigate

前端 未结 3 1922
不知归路
不知归路 2021-01-18 00:07

I am trying to navigate between two screen with the help of react-navigation. I am able to access navigate inside the render method as

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-18 00:53

    That happens because you are not destructuring it from the props as you have done in your render() function

    onPressButton = () => {
        var {navigate} = this.props.navigation;
        var options = {
          title: strings.app_name,
          content: strings.create_message,
          positiveText: strings.OK,
          onPositive: () => navigate("DashboardScreen")
        };
        var dialog = new DialogAndroid();
        dialog.set(options);
        dialog.show();
      }
    

提交回复
热议问题