diff --git a/src/RCTAsyncStorage.expo.js b/src/RCTAsyncStorage.expo.js index 3ce3183f..607eecc1 100644 --- a/src/RCTAsyncStorage.expo.js +++ b/src/RCTAsyncStorage.expo.js @@ -7,7 +7,18 @@ * 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; +const {NativeModules, TurboModuleRegistry} = require('react-native'); -export default RCTAsyncStorage; \ No newline at end of file +let RCTAsyncStorage; + +// TurboModuleRegistry falls back to NativeModules +// so we don't have to try go assign NativeModules' +// counterparts if TurboModuleRegistry would resolve +// with undefined. +if (TurboModuleRegistry) { + RCTAsyncStorage = TurboModuleRegistry.get("AsyncSQLiteDBStorage") || TurboModuleRegistry.get("AsyncLocalStorage"); +} else { + RCTAsyncStorage = NativeModules.AsyncSQLiteDBStorage || NativeModules.AsyncLocalStorage; +} + +export default RCTAsyncStorage;