You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No number is allowed in TextInput. Value cannot be updated when a number is entered on the keyboard.
Reproducible Demo
demo:
classInputTextextendsReact.Component{constructor(props){super(props);this.state={value: ''}}render(){<View><TextInputvalue={this.state.value}onChangeText={(val)=>{if(/[0-9]/.val)returnToast.info('Input of numbers is not allowed');this.setState({value: val});}}/></View>}}
Although numbers are forbidden, they are displayed first and then disappear. How to Avoid Input Numbers in Input Box
The text was updated successfully, but these errors were encountered:
Although briefly displaying the number may be unavoidable because the value has to travel across the bridge, you can reduce this time drastically by always setting the value (even if it contains a number), but with the number filtered out. This triggers a state change and an immediate re-render, making the time the number is displayed minimal (0 in most cases): https://snack.expo.io/@bartolkaruza/rn-#22384
Environment
Description
No number is allowed in TextInput. Value cannot be updated when a number is entered on the keyboard.
Reproducible Demo
demo:
Although numbers are forbidden, they are displayed first and then disappear. How to Avoid Input Numbers in Input Box
The text was updated successfully, but these errors were encountered: