From 194e08f8392c6aa4a82faf5b4b4e2aff7a60c181 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Fri, 22 Nov 2019 08:22:46 -0800 Subject: [PATCH] Prefer PlatformLocalStorage Over Other Native Modules We currently try to load builtin native modules before trying to fallback to platform provided native modules. Reversing this order allows the platform to provide the AsyncStorage implementtion even if on a platform that async-storage already supports. This ability can be useful in hosted scenarios where we may want more control over how data for an individual React Native instance is stored. --- lib/AsyncStorage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/AsyncStorage.js b/lib/AsyncStorage.js index 0619b234..bd229f72 100644 --- a/lib/AsyncStorage.js +++ b/lib/AsyncStorage.js @@ -14,9 +14,9 @@ const {NativeModules} = require('react-native'); const RCTAsyncStorage = + NativeModules.PlatformLocalStorage || // Support for external modules, like react-native-windows NativeModules.RNC_AsyncSQLiteDBStorage || - NativeModules.RNCAsyncStorage || - NativeModules.PlatformLocalStorage; // Support for external modules, like react-native-windows + NativeModules.RNCAsyncStorage; if (!RCTAsyncStorage) { throw new Error(`[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.