launchdarkly / js-core

LaunchDarkly monorepo for JavaScript SDKs
Other
12 stars 12 forks source link

Incompatible with RN New Architecture #462

Closed artyorsh closed 1 month ago

artyorsh commented 1 month ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch @launchdarkly/react-native-client-sdk@10.1.3 for the project I'm working on.

Enabling new architecture in react native project produces runtime errors while trying to access nullable NativeModules.SettingsManager.

Here is the diff that solved my problem:

diff --git a/node_modules/@launchdarkly/react-native-client-sdk/dist/src/platform/locale.js b/node_modules/@launchdarkly/react-native-client-sdk/dist/src/platform/locale.js
index 725ef98..c4cdcdd 100644
--- a/node_modules/@launchdarkly/react-native-client-sdk/dist/src/platform/locale.js
+++ b/node_modules/@launchdarkly/react-native-client-sdk/dist/src/platform/locale.js
@@ -5,7 +5,7 @@ import { NativeModules, Platform } from 'react-native';
  * https://dev.to/medaimane/localization-and-internationalization-in-react-native-reaching-global-audiences-3acj
  */
 const locale = Platform.OS === 'ios'
-    ? NativeModules.SettingsManager.settings.AppleLocale // iOS
+    ? NativeModules.SettingsManager?.settings.AppleLocale // iOS
     : (_a = NativeModules.I18nManager) === null || _a === void 0 ? void 0 : _a.localeIdentifier;
 export default locale;
 //# sourceMappingURL=locale.js.map
\ No newline at end of file

This issue body was partially generated by patch-package.

yusinto commented 1 month ago

Thanks for submitting this. We are looking into it. Internally logged as 244927.