CaioQuirinoMedeiros/react-native-mask-input

Masks.BRL_CURRENCY begin in 0,01

rodrigomoraes opened this issue · 2 comments

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

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