skip to Main Content

ERROR Error: RNEncryptedStorage is undefined, js engine: hermes
at ContextNavigator (http://192.168.0.105:8081/node_modules%5Cexpo-router%5Centry.bundle//&platform=android&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:148715:24)
….

..
.

It gives an error when I try to execute this:

const token = await EncryptedStorage.getItem("user-token");
await EncryptedStorage.removeItem("user-token");

2

Answers


  1. As you’re using Expo, I recommend using SecureStore https://docs.expo.dev/versions/latest/sdk/securestore/

    Usage overview:

    Set a value

    await SecureStore.setItemAsync(key, value);
    

    Get a value

    const result = await SecureStore.getItemAsync(key);
    
    Login or Signup to reply.
  2. Expo supports also AsyncStorage https://docs.expo.dev/versions/latest/sdk/async-storage/

    I recommend using it.

    To store data use this

    const storeData = async (value) => {
      try {
        const jsonValue = JSON.stringify(value)
        await AsyncStorage.setItem('@storage_Key', jsonValue)
      } catch (e) {
        // saving error
      }
    

    To retrieve data instead use this:

    const getData = async () => {
      try {
        const jsonValue = await AsyncStorage.getItem('@storage_Key')
        return jsonValue != null ? JSON.parse(jsonValue) : null;
      } catch(e) {
        // error reading value
      }
    }
    

    Use this as a base, as this two functions retrieve objects. If you only want to store a single string or value those are not ok.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search