react-native-i18n icon indicating copy to clipboard operation
react-native-i18n copied to clipboard

locale.split is not a functi on. (In 'locale.split("-")', 'locale.split' is undefined)

Open abdulkabirpatel opened this issue 3 years ago • 2 comments

I am getting error [Thu Dec 10 2020 23:42:05.669] ERROR TypeError: locale.split is not a functi on. (In 'locale.split("-")', 'locale.split' is undefined)

whenever I add

const langCheck=async()=>{

const languageCode = await AsyncStorage.getItem(language);

I18n.locale = languageCode; }

abdulkabirpatel avatar Dec 10 '20 18:12 abdulkabirpatel

maybe try to change it to this I18n.locale = languageCode.toString() I think you are sending a non-string value to a function that only accepts strings if my fix didn't work you can pass your asyncStorage value to a function and then make it a string, then pass it to a state then use it in I18n.locale. Also if you are using the i18njs library it's i18n.locale not I18n.locale

navidabasi avatar Jan 23 '22 12:01 navidabasi