Skip to content Skip to sidebar Skip to footer

Arrow Functions With Async And Await In React Native

I am trying to save data in AsyncStorage in react-native. I want to save it asynchronous so using async and await keyword. async onPositiveClickListener = () => { // user

Solution 1:

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);
    }
  };

Post a Comment for "Arrow Functions With Async And Await In React Native"