当我隐藏我的密码时,反应原生密码冻结到开始


const [password, setPassword] = useState('')
const [passwordVisibility, setPasswordVisibility] = useState(false);
<View style={styles.inputContainer}>
<TextInput
name="password"
style={styles.inputField}
autoCapitalize='none'
value={password}
autoCorrect={false}
textContentType="newPassword"
onChangeText={onChangeText}
placeholder="Password"
enablesReturnKeyAutomatically
secureTextEntry={passwordVisibility}
/>
<Pressable onPress={()=>{setPasswordVisibility(!passwordVisibility) , console.log(password)}}>
<Icon name={passwordVisibility == true ? 'eye' : 'eye-off' } size={23} color='purple' />
</Pressable>

</View>

这是我的代码。当我隐藏我的密码在反应原生密码冻结到开始。我该如何解决这个

尝试更改

onChangeText={onChangeText}onChangeText={value => setPassword(value)}

并将password赋值给TextInput

上的值prop
<TextInput
// current props
onChangeText={value => setPassword(value)}
value={password}
/>

相关内容

  • 没有找到相关文章

最新更新