Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap the native module used when in Expo managed workflow #368

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1,2 @@
# Expo managed workflow supported native backend
/src/RCTAsyncStorage.expo.js @brentvatne
7 changes: 1 addition & 6 deletions src/AsyncStorage.native.js
Expand Up @@ -11,12 +11,7 @@

'use strict';

const {NativeModules} = require('react-native');

const RCTAsyncStorage =
NativeModules.PlatformLocalStorage || // Support for external modules, like react-native-windows
NativeModules.RNC_AsyncSQLiteDBStorage ||
NativeModules.RNCAsyncStorage;
import RCTAsyncStorage from './RCTAsyncStorage';

if (!RCTAsyncStorage) {
throw new Error(`[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
Expand Down
13 changes: 13 additions & 0 deletions src/RCTAsyncStorage.expo.js
@@ -0,0 +1,13 @@
/**
* Expo managed apps don't include the @react-native-community/async-storage
* native modules yet, but the API interface is the same, so we can use the version
* exported from React Native still.
*
* If in future releases (eg: @react-native-community/async-storage >= 2.0.0) this
* will likely not be valid anymore, and the package will need to be included in the Expo SDK
* to continue to work.
*/
const {NativeModules} = require('react-native');
const RCTAsyncStorage = NativeModules.AsyncSQLiteDBStorage || NativeModules.AsyncLocalStorage;

export default RCTAsyncStorage;
8 changes: 8 additions & 0 deletions src/RCTAsyncStorage.js
@@ -0,0 +1,8 @@
const {NativeModules} = require('react-native');

const RCTAsyncStorage =
NativeModules.PlatformLocalStorage || // Support for external modules, like react-native-windows
NativeModules.RNC_AsyncSQLiteDBStorage ||
NativeModules.RNCAsyncStorage;

export default RCTAsyncStorage;