此语言是React母语
export default function forgotPassword(props) {
const [hidePassword, showPassword] = useState(true);
const managePasswordVisibility = () => {
showPassword({ hidePassword: !hidePassword });
};
return (
<View style={styles.textBoxBtnHolder}>
<TextInput
secureTextEntry={hidePassword}
textContentType="password"
style={styles.textBox}
/>
<TouchableOpacity
activeOpacity={0.8}
style={styles.visibilityBtn}
onPress={managePasswordVisibility}
>
<Image
source={
hidePassword
? require("../../assets/icons/hide.png")
: require("../../assets/icons/view.png")
}
style={styles.btnImage}
/>
</TouchableOpacity>
</View>
);
}
如果我使用钩子显示错误并且密码未显示刚刚被隐藏并且发出警告,则无法在securityTextEntry中使用隐藏密码。请提供任何帮助
failed prop 'secureTextEntry' of type 'object' suppied to 'forwardRef(TextInput) expected boolen
答案 0 :(得分:0)
您不必在showPassword()
内部使用对象,它只会更改hidePassword
的值,因此
showPassword(!hidePassword);