I am trying to save data in AsyncStorageto react-native. I want to keep it asynchronously, using the keyword asyncand await.
async onPositiveClickListener = () => {
try {
await AsyncStorage.setItem("@ProductTour:key", "true");
const { navigate } = this.props.navigation;
navigate("DashboardScreen");
} catch (error) {
console.log(error);
}
};
I get an error while saving the program
SyntaxError: Unexpected token, expected ( (40:32)
38 | };
39 |
> 40 | async onPositiveClickListener = () => {
| ^
41 |
42 | try {
43 | await AsyncStorage.setItem("@ProductTour:key", "true");
Hide Stack Trace
SyntaxError: Unexpected token, expected ( (40:32)
38 | };
39 |
> 40 | async onPositiveClickListener = () => {
| ^
41 |
42 | try {
source
share