我需要快速帮助。当我输入无效的电子邮件并按Enter时,它会在警报提示中向我显示电子邮件无效,但是每当我在文本框中键入内容来更正我的电子邮件时,警报提示都会每次显示。我需要摆脱这些。请有人帮帮我。
<View style={styles.inputContainer}>
<TextInput
autoCapitalize="none"
autoCompleteType="off"
autoCorrect={false}
value={username}
onChangeText={(text) => this.setState({username: text})}
placeholder="Email"
underlineColorAndroid="transparent"
style={styles.textInput}></TextInput>
</View>
错误警报提示代码
<View>{this.state.error ? Alert.alert('Email invalid') : null}</View>
当错误this.state.error
仍然存在true
并且textInput
在每个渲染中输入文本时,此错误将再次执行,针对此问题的解决方案是从渲染中删除此错误状态,或者在显示错误后将状态设置为false。
<View>{this.state.error ? Alert.alert('Email invalid') : null}</View>
从渲染中删除上面的行,或者通过将您的error state
放到false
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句