CaioQuirinoMedeiros / react-native-mask-input

🎭:iphone: A simple and effective Text Input with mask for ReactNative on iOS and Android. Includes obfuscation characters feature.

Home Page:https://www.npmjs.com/package/react-native-mask-input

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Masks.BRL_CURRENCY begin in 0,01

rodrigomoraes opened this issue · 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...