CaioQuirinoMedeiros/react-native-mask-input

useMaskedInputProps should pass unmasked as second parameter to onChangeText

Closed this issue · 2 comments

The mask is only for show and there should be another parameter called unmasked that passes unformatted, raw text to the function. The raw value should also be converted to masked one.

import { Input } from 'native-base'
import { Masks } from 'react-native-mask-input';

function MyComponent() {
  const [phone, setPhone] = React.useState('');

  const maskedInputProps = useMaskedInputProps({
    value: phone, // <------ This should be unmasked value and should be converted by hook to masked
    onChangeText: setPhone, // <---------------- This should also pass unmasked value as second parameter
    mask: Masks.BRL_PHONE,
  });

  return <Input {...maskedInputProps} />
}

This was already implemented, @asfandyarsheikh.

This is working correctly, the value can be masked or unmasked and the function does receive unmasked value as second parameter (also receive obfuscated value as third parameter)