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
<TextInput
// current props
onChangeText={value => setPassword(value)}
value={password}
/>