alkafinance / react-native-amount-input

⚛️ React Native JS-only amount (decimal) input component
MIT License
13 stars 0 forks source link

Can't find variable: Intl #4

Open vchikalkin opened 4 years ago

vchikalkin commented 4 years ago

image

janaka120 commented 4 years ago

@djChika Did you find any solution for this?

Gabrielhvcardoso commented 4 years ago

Same error, located on ./node_modules/react-native-amount-input/AmountInput.js, probably at line 22:

const formatter = new Intl.NumberFormat('en-US, {
  style: 'currecy',
  currency: currency || 'USD',
});
return formatter.format(0)[0];
Grohden commented 4 years ago

Intl seems to be a built in, are you using TS? probably adding "lib": ["es6"], to tsconfig may fix this for you.

On the other hand, the lib could be using toLocaleString instead of Intl:

(0).toLocaleString('en-US', { style: 'currency', currency: currency || 'USD' })

Edit: nop, on android I get the same Intl error, this seems to be a issue with hermes not supporting Intl, also, using toLocaleString on android returns a default string, not a formatted one (because Intl is not present there)

vchikalkin commented 4 years ago

@janaka120 @Gabrielhvcardoso @Grohden

I switched to react-native-masked-text

Grohden commented 4 years ago

@djChika tried that but had some problems (zeroes added at end are ignored/removed).

Been using a personal solution - for my specific use case - if anyone's interested: https://gist.github.com/Grohden/23984bf94ec2f3a8a9b2a51254b68ee5

Gabrielhvcardoso commented 4 years ago

@djChika tried that but had some problems (zeroes added at end are ignored/removed).

Been using a personal solution - for my specific use case - if anyone's interested: https://gist.github.com/Grohden/23984bf94ec2f3a8a9b2a51254b68ee5

It sounds good, thanks man!

Gabrielhvcardoso commented 3 years ago

I've found some a pure javascript solution that have been so usefull to format currencies, I'll provide this snack if someone has interest.

allysonfield commented 3 years ago

I switched to react-native-masked-text, too