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

Invalid character outside of mask appearing before being removed

VaiteaBimOne opened this issue · comments

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

Screen.Recording.2023-05-12.at.2.15.35.PM.mov
  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!

Welcome to React Native