Cannot import * as RNLocalize from "react-native-localize" without error on iOS and Android

See original GitHub issue

Bug

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

  1. npm i react-native-localize
  2. Edit src/index.js and add import * as RNLocalize from "react-native-localize";
  3. Run code …

Describe what you expected to happen:

  1. I expect to be able to import on both iOS and Android
  2. both fail

Reproducible sample code

import * as RNLocalize from "react-native-localize";

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
zoontekcommented, Dec 30, 2019

@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.

3reactions
zoontekcommented, Dec 30, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found