Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

React Native Encrypted Storage Error: RNEncryptedStorage is undefined #34

Closed
0526tracy opened this issue Dec 17, 2020 · 4 comments
Closed

Comments

@0526tracy
Copy link

0526tracy commented Dec 17, 2020

Hi !is anyone here ever encountered this?

Im using expo in my current project, then i tried to use react-native-encrypted-storage
I follow the steps here (https://www.npmjs.com/package/react-native-encrypted-storage)

but i got this error when i run expo start

image

@0526tracy 0526tracy changed the title React Native Encrypted Storage error: Error: RNEncryptedStorage is undefined React Native Encrypted Storage Error: RNEncryptedStorage is undefined Dec 17, 2020
@emeraldsanto
Copy link
Owner

This module does not support Expo since it uses native code.

@phuvinhng
Copy link

I don't use expo but I still get that error !! @emeraldsanto

@CaLxCyMru
Copy link

If someone happens to stumble across this issue try the following steps:

  1. Run cd ios && pod install && cd ..
  2. Stop all metro servers
  3. Re-build the iOS app with yarn run ios

Final step seems to have resolved the issue for me 👌

@aymkin
Copy link

aymkin commented Mar 2, 2022

This is not an expo. I try to run the test.

image

The project has a mock for encrypted storage.

// jest.config.ts

setupFiles: ['<rootDir>/test/setup.ts'],

// test/setup.ts

import 'react-native'

// libraries to mock
import './mock-safe-area-context'
import './mock-react-native-encrypted-storage'

jest.useFakeTimers()
declare global {
  // eslint-disable-next-line no-underscore-dangle
  let __TEST__
}

// test/mock-react-native-encrypted-storage.ts

const RNEncryptedStorage = {
  setItem: jest.fn(() => Promise.resolve()),
  getItem: jest.fn(() => Promise.resolve('{ "foo": 1 }')),
  removeItem: jest.fn(() => Promise.resolve()),
  clear: jest.fn(() => Promise.resolve()),
};

export default RNEncryptedStorage;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants