Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read property 'AppleLocale' of undefined

In my React Native app (version 0.77.1), I get the error 'TypeError: Cannot read property 'AppleLocale' of undefined' on iOS. I use 'AppleLocale' in the following code:

Simulator Screenshot 'AppleLocale' of undefined

AppleLocale is fetched here

  Platform.OS === 'ios'
    ? NativeModules.SettingsManager.settings.AppleLocale ||
      NativeModules.SettingsManager.settings.AppleLanguages[0] // iOS 13
    : NativeModules.I18nManager.localeIdentifier;
like image 590
Sidox Avatar asked Sep 03 '25 04:09

Sidox


1 Answers

Instead of NativeModules.SettingsManager.settings.AppleLocale, it should be NativeModules.SettingsManager.getConstants().settings.AppleLocale in newer versions of React Native.

like image 163
Syed Zawwar Ahmed Avatar answered Sep 04 '25 20:09

Syed Zawwar Ahmed