react-native-i18n: Undefined is not an object (evaluating 'RNI18n.languages')
I have this problem only when using EXPO (ios, android). When building with Xcode - don’t have this problem.
Error in this line
I18nJs.locale = RNI18n.languages[0];
export const getLanguages = RNI18n.getLanguages;
I commented this lines and add I18nJs.locale = 'en';
this help but not resolves the issue.
I used react-native default pack and add EXPO
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 16
I updated the dependencies with npm-check-updates -u; npm install && npm install --only=dev and then i had the same problem on iOS. How i solved it was to combine the series of suggestions. First unlink and then link again
$react-native unlink react-native-i18n $react-native link
then stop and restart the react packager.
On Android it gave me error that it could not import “com.i18n.reactnativei18n.ReactNativeI18n” and “new RNI18nPackage()” method does not exist. This was because the new version I updated to has replaced them so I had to remove them and
import com.AlexanderZaytsev.RNI18n.RNI18nPackage; import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
and use these methods in the getPackages() new RNI18nPackage(), new ReactNativeConfigPackage()
according to: [https://github.com/AlexanderZaytsev/react-native-i18n/issues/95]
Happens to me as well, works fine on iOS but fails in Android, I followed the Android setup guide to no avail
in your project
$ react-native link
and reboothttps://github.com/AlexanderZaytsev/react-native-i18n#manual-setup https://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-2
#126
It appears that the react-native link does not work, even though the console says it did. I had to add the project to Libraries then add the .a file in build phases, then it worked.
People please! when you link a new library in react native, you MUST stop your npm packager (the console with
npm start
). You must restart your npm start and run react-native run-ios o react-native run-android again! I had the same problem and that was the problem, the library was linked but you must restart your packager so the library can start working.I’m getting “Cannot read property ‘getLanguages’ of undefined”. Steps I followed: