CaioQuirinoMedeiros / react-native-mask-input

🎭:iphone: A simple and effective Text Input with mask for ReactNative on iOS and Android. Includes obfuscation characters feature.
https://www.npmjs.com/package/react-native-mask-input
MIT License
309 stars 31 forks source link

Invalid character outside of mask appearing before being removed #38

Closed VaiteaBimOne closed 1 year ago

VaiteaBimOne commented 1 year ago

I tried different example et tried with a custom mask. Everything is working fine but if I have a mask to allow only numerical character for example, adding a letter will show fro a split second before being removed.:

https://github.com/CaioQuirinoMedeiros/react-native-mask-input/assets/128174796/9cf59855-1b72-4fe3-a95a-2442e51c1bad

  const [creditCard, setCreditCard] = React.useState('');

  return (
    <MaskInput
      value={creditCard}
      onChangeText={(masked, unmasked) => {
        setCreditCard(masked); // you can use the unmasked value as w

        // assuming you typed "9" all the way:
        console.log(masked); // (99) 99999-9999
        console.log(unmasked); // 99999999999
      }}
      mask={['(', /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]}
    />
  );

Thanks!

CaioQuirinoMedeiros commented 1 year ago

Welcome to React Native