Go Pro Sign Up Login
0 days 0 hrs 0 min 0 sec

Summer Sale

50% off Level Up Pro until you unsubscribe.
Get access to ALL 128 courses on Level Up Tutorials

This is your last chance to get Level Up Pro for $145/year.

or Learn More
Moon Moon

Buy Now and unlock this series







yours forever

Become a Pro and unlock everything




per month

Native Base For Native Styles


Become a pro to download code and videos



over 3 years ago [edited]

If you're getting errors in your Android emulator like "ReferenceError: Can't find variable: Intl", or "ReferenceError: No locale data has been provided for this object yet.", that's because the JavaScriptCore engine bundled with react-native for Android isn't providing "Intl" as a global var, nor populating the available locales. iOS handles "Intl" without issue because it has its own JavaScriptCore right out of the box.

In order to make this work on Android, you'll need to both install the "Intl" polyfill, and import the locales you want from the same package.

  1. First, install the polyfill into your project:
npm i intl --save
  1. Then, import the Intl object and one or more locales from the package:
import 'intl';
import 'intl/locale-data/jsonp/en';

This should resolve any Intl-related issues you may have in Android!

For bonus points, you may choose to only import Intl and locale data for platforms which don't already include it. Since you cannot use Platform.OS to dynamically load imported dependencies, the only option may be to use separate files with the appropriate ".ios.js" and ".android.js", which is not ideal.

Alternatively, you might choose to bundle a newer JSC with your Android application using https://github.com/react-native-community/jsc-android-buildscripts. Read more at AirBnb's engineering blog: https://medium.com/airbnb-engineering/react-native-at-airbnb-the-technology-dafd0b43838.

Want to join the conversation?

Become a Pro member today!