Arrow functions with async and await in react native

前端 未结 1 1138
别跟我提以往
别跟我提以往 2021-01-04 07:13

I am trying to save data in AsyncStorage in react-native. I want to save it asynchronous so using async and await keyword

相关标签:
1条回答
  • 2021-01-04 07:35

    Async named arrow function should be declared like

    const onPositiveClickListener = async () => {
        // user has completed product tour_end
        try {
          await AsyncStorage.setItem("@ProductTour:key", "true");
          const { navigate } = this.props.navigation;
          navigate("DashboardScreen");
        } catch (error) {
          console.log(error);
        }
      };
    
    0 讨论(0)
提交回复
热议问题