RNLocalize gets an undefined object on RNLocalize.initialContants
See original GitHub issueHello !
We used react-native-languages
with i18n-js
in our app to easly manage the translations. Now that it has been updated and that we’ve done the migration, we faced a strange exception as described below.
Describe your environment
- react-native-localize v 1.0.1
- react-native v 0.57.7
- Target platform: both
- Device : Android Virtual Device
- OS version: Android 6.0
- DevTools: Android Studio v 3.1.4 with build tools v 27.0.3
How to repeat issue and example
Before the update to RNLocalize, everything worked fine, I did nothing more than copying the example. After the update, I followed the steps described here.
- Unlink then uninstall react-native-languages with npm
- Install then link react-native-localize
- Edited my i18n.js file to be the exact same as in the link above
react-native run-android
now instantly throws me this exceptionundefined is not an object (evaluating 'RNLocalize.initialContants')
even in the console it’s the only thing printed.
I’m not really confident with react-native and I don’t have any clue about what’s happening.
I created a new project with only react-native-localize
and i18n-js
installed, but I got the same result except the value was null
and not undefined
.
Basically just using import * as RNLocalize from 'react-native-localize
throws this exception.
Have you any clues about what could cause this issue ?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:44 (12 by maintainers)
I did have the same errors on iOS. (did not test android yet). Manual linking did work, adding the RNLocalize.xcodeproj to the libraries on the project navigator AND (missing in the docs) adding libRNLocalize.a in the linked frameworks and libraries in the general tab of the target app.
So it seems the automatic linking is not working as advertised.
@duluong This package will not works with Expo (you can’t install native packages in Expo without exjecting to Expokit). Check the Expo documentation to achieve the same effect: https://docs.expo.io/versions/v33.0.0/sdk/localization/