Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

await is a reserved word error in Expo XDE for React Native

Right to the point:

I'm using Expo XDE with react-native to build a cross-platform mobile app.

I want to save and retrieve a couple of variables using AsyncStorage ("localstorage" alternative in react-native).

After adding the pieces of code to store and retrieve,

enter image description here

Expo XDE is showing the following error when building the JavaScript bundle: "await is a reserved word"

enter image description here

According to the documentation (https://facebook.github.io/react-native/docs/asyncstorage.html), I got to use "await" when accessing AsyncStorage.

Any ideas? Is it a problem related to Expo XDE only?

Thanks!!

like image 895
theRonny Avatar asked Dec 31 '25 10:12

theRonny


1 Answers

To use await, your function including const username = await AsyncStorage.getItem(); needs to be async.

You can do like this :

async myfunction() {
  ...
  const username = await AsyncStorage.getItem();
  ...
}
like image 167
Antoine Grandchamp Avatar answered Jan 03 '26 14:01

Antoine Grandchamp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!