react-native-masked-text
react-native-masked-text copied to clipboard
rawText returning undefined
Hello. I'm trying to use rawValue for saving in state, but always get undefined. maskedValue returns correct.
<TextInputMask
customTextInput={TextInput}
customTextInputProps={{
mode: 'outlined',
label: 'CPF',
}}
type={'cpf'}
value={this.state.cpf}
includeRawValueInChangeText={true}
onChangeText={(maskedText, rawText) => {
console.log(maskedText, rawText)
this.setState({ cpf: maskedText })
}}
/>
Using 1.12.0 version.
Also having this issue.
Using 1.12.3 version
Same here !
Hi guys!
I'm trying this sample:
export default class WithRawValueInChangeText extends React.Component {
constructor(props) {
super(props)
this.state = {
value: '',
raw: ''
}
}
render() {
return (
<View style={container}>
<Text>With raw value in change text</Text>
<TextInputMask
type={'cpf'}
value={this.state.value}
includeRawValueInChangeText={true}
onChangeText={(text, rawValue) => {
this.setState({
value: text,
raw: rawValue
})
}}
/>
<Text>Value: {this.state.value}</Text>
<Text>Raw: {this.state.raw}</Text>
</View>
)
}
}
And it's working properly =/.
Could you provide some additional info, like:
- Are you using typescript?
- Device and OS versions
If you want, you can check this repo: https://github.com/benhurott/react-native-masked-text-samples
It doesn't works with phone number or custom mask.
Hi guys!
I'm trying this sample:
export default class WithRawValueInChangeText extends React.Component { constructor(props) { super(props) this.state = { value: '', raw: '' } } render() { return ( <View style={container}> <Text>With raw value in change text</Text> <TextInputMask type={'cpf'} value={this.state.value} includeRawValueInChangeText={true} onChangeText={(text, rawValue) => { this.setState({ value: text, raw: rawValue }) }} /> <Text>Value: {this.state.value}</Text> <Text>Raw: {this.state.raw}</Text> </View> ) } }
And it's working properly =/.
Could you provide some additional info, like:
- Are you using typescript?
- Device and OS versions
If you want, you can check this repo: https://github.com/benhurott/react-native-masked-text-samples
it would be great if it works on every type not only cpf
Do you have any ideas how to fix it?
Do you have any ideas how to fix it?
Yeah, this object is a type NativeSyntheticEvent<TextInputChangeEventData> for get value use: value.nativeEvent.text
Or
use onChangeText, instead of onChange