Masks.BRL_CURRENCY begin in 0,01
rodrigomoraes opened this issue · 2 comments
rodrigomoraes commented
Have anyway to use Masks.BRL_CURRENCY begin in Centavos and not in Real? Actually if we type 1, it format to R$ 1, in my case should be R$ 0,01
CaioQuirinoMedeiros commented
No.
You should try https://github.com/CaioQuirinoMedeiros/react-native-currency-input
rodrigomoraes commented
Oh, i didn't know about this solution... Anyway i do this to solve my problem
const formatAmountToCents = (value: any) => {
const amountFormated = (value / 100).toFixed(2).replace(".", "");
return amountFormated;
};
<MaskInput
placeholder="R$ 0,00"
mask={Masks.BRL_CURRENCY}
value={formatAmountToCents(amount)}
onChangeText={(masked, unmasked) => {
setAmount(unmasked);
}}
/>
And It Works!
But i thank you to show me the real solution...