diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..7adc5e50 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Expo managed workflow supported native backend +/src/RCTAsyncStorage.expo.js @brentvatne \ No newline at end of file diff --git a/src/AsyncStorage.native.js b/src/AsyncStorage.native.js index 647278de..b87e0bd0 100644 --- a/src/AsyncStorage.native.js +++ b/src/AsyncStorage.native.js @@ -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. diff --git a/src/RCTAsyncStorage.expo.js b/src/RCTAsyncStorage.expo.js new file mode 100644 index 00000000..3ce3183f --- /dev/null +++ b/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; \ No newline at end of file diff --git a/src/RCTAsyncStorage.js b/src/RCTAsyncStorage.js new file mode 100644 index 00000000..eb2356e1 --- /dev/null +++ b/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; \ No newline at end of file