react-native-masked-text
react-native-masked-text copied to clipboard
Mask type not supported
I'm trying to call TextInputMask inside a global component, but I got this error every time:
here is my code:
function Input({ style, icon, ...rest }, ref) {
return (
<Container style={style}>
{icon && <Icon name={icon} size={20} color="rgba(255, 255, 255, 0.6)" />}
<TextInputMask {...rest} ref={ref} />
</Container>
);
}
I've already tried to call it directly inside my View component and it worked, but inside a global one, it doesn't
Hi @raulmo1337 could you add a print of the ...rest
data?
I'm thinking you are trying to pass an invalid prop to the input.
Hi @benhurott. here is the ...rest data:
{
"type": "cel-phone",
"options": {
"maskType": "BRL",
"withDDD": true,
"dddMask": "(99) "
},
"placeholder": "phone",
"keyboardType": "phone-pad",
"returnKeyType": "next",
"onSubmitEditing": " onSubmitEditing() ",
"value": "",
"onChangeText": " bound dispatchAction() "
}
I don't think this is the problem, because even when no params are passed to the component it still showing this error
I've changed the "function Input({ style, icon, ...rest }, ref)" to function Input({ style, type, options , icon, ...rest }, ref). I put this props separeted like this: <TextInputMask {...rest} ref={ref} style={styles.TextInput} placeholderTextColor="#FFF" type={type} options={options} /> And it worked quite well to me.
Adding type="custom"
e.g <TextInputMask {...props} type="custom" options={{ mask: phoneMask }} />
worked for me.
Hello guys, my problem was because I did not enter the "type" property in the next screen component that also has a mask