Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Intl.NumberFormat with react native?

Im trying to convert a number to price format in react native. How to use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat (Intl.NumberFormat) this with react native?

like image 666
m9m9m Avatar asked Oct 15 '18 08:10

m9m9m


People also ask

Can I use INTL IN react native?

React Native​ If you're using react-intl in React Native, make sure your runtime has built-in Intl support (similar to JSC International variant).

How do you use NumberFormat in react?

Usage. import NumberFormat from 'react-number-format'; //or import { default as NumberFormat } from 'react-number-format'; In typescript you also have to enable "esModuleInterop": true in your tsconfig. json (https://www.typescriptlang.org/docs/handbook/compiler-options.html).

What is Intl NumberFormat?

The Intl.NumberFormat object enables language-sensitive number formatting.


Video Answer


1 Answers

Looks like you need the international version of JSC: Android: https://github.com/react-native-community/jsc-android-buildscripts#international-variant

For iOS you'd need to use Intl.js polyfill https://github.com/andyearnshaw/Intl.js/

like image 121
Long Ho Avatar answered Sep 30 '22 19:09

Long Ho