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>
这是我的代码。当我在react-native中隐藏我的密码时,密码冻结在开头。我该如何修复这个问题
1条答案
按热度按时间hyrbngr71#
试试换
onChangeText={onChangeText}
至onChangeText={value => setPassword(value)}
并将
password
赋给TextInput
上的值prop