Closed
Description
Please provide all the information requested. Issues that do not follow this format are likely to stall.
Description
TextInput component shows different value than what is passed in through the value prop
React Native version:
0.62.0
Steps To Reproduce
- Type '2' into input
- Type 'f' into input twice
Expected Results
Expected to only see integers in the text input
Snack, code example, screenshot, or link to a repository:
const onChange = (value: string) => {
const trimmed = value.replace(/\D/g,'');
props.onChange(trimmed.substring(0, Math.min(trimmed.length, props.maxDigits)));
}
console.log('props.value', props.value)
return (
<TextInput
onChangeText={onChange}
value={props.value}
/>
);
passed in onChange function is just onChangeWeight:
const [weight, setWeight] = useState('');
const onChangeWeight = (w: string) => {
return setWeight(w);
};