Cannot import * as RNLocalize from "react-native-localize" without error on iOS and Android
See original GitHub issueBug
Writing import * as RNLocalize from "react-native-localize"; is breaking my iOS and Android app:
Environment info
Android
TypeError: null is not an object (evaluating 'RNLocalize.initialConstants')
iOS
Invariant Violation: Native module cannot be null.
Library version: 1.3.1 └── react-native@0.61.4
Steps To Reproduce
npm i react-native-localize- Edit
src/index.jsand addimport * as RNLocalize from "react-native-localize"; - Run code …
Describe what you expected to happen:
- I expect to be able to import on both iOS and Android
- both fail
Reproducible sample code
import * as RNLocalize from "react-native-localize";
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
react native - RNLocalize gets an undefined object on ...
It seems to be you didn't properly linking the RNLocalize with your project. In terminal run - react-native link react-native-localize and ...
Read more >react-native-localize - npm
A toolbox for your React Native app localization.. Latest version: 2.2.4, last published: 3 months ago. Start using react-native-localize in ...
Read more >How to get current country of Device in React Native (iOS and ...
import * as RNLocalize from "react-native-localize"; console.log(RNLocalize.getLocales()); console.log(RNLocalize.getCurrencies()); console.log(RNLocalize.
Read more >A toolbox for Your React Native App Localization - Morioh
node_modules/react-native-localize/android') ... Basic usage example ```js import * as RNLocalize from "react-native-localize"; console.log(RNLocalize.
Read more >Troubleshooting common React Native bugs - LogRocket Blog
The React Native team has made this error more descriptive since the last ... In that case, you'd have to import it without...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kopax Expo makes some changes inside RN (it even started as a fork) and they reimplement a huge part of the RN community modules (sometimes it’s just a wrapper, sometimes the code is “similar” sometimes it’s written from the ground).
I’m really not a fan of the approach too: it creates fragmentation in the RN community. We should join forces instead of having multiple ways to do the same thing.
Some users report issues with Expo. As this package is for bare react-native installs, I suggest you to use https://docs.expo.io/versions/latest/sdk/localization/ instead.