[英]Autofill for emails on iOS using React Native TextInput
I want to have suggestions of emails when filling out my login and sign up fields on iOS.在 iOS 上填写登录和注册字段时,我希望收到电子邮件建议。
This is my TextInput for an email field:这是我的电子邮件字段的 TextInput:
<TextInput
style={styles.text}
placeholder={placeholder}
textContentType={'emailAdress'}
placeholderTextColor={PLACEHOLDER_GRAY}
onChangeText={onTextChange}
keyboardType={'email-address'}
autoCorrect={true}
autoCapitalize={'none'}
/>
This works just fine IF I don't have another InputText with the secureTextEntry
property set.如果我没有另一个设置了
secureTextEntry
属性的InputText,这可以正常工作。 But I do need to use secureTextEntry
property for password fields.但我确实需要对密码字段使用
secureTextEntry
属性。 However, these properties are having some sorte of conflict.但是,这些属性存在某种冲突。 If I remove the TextInputs related to passwords (or even just the
secureTextEntry
property from those inputs) I get the email suggestions.如果我删除与密码相关的 TextInputs(甚至只是从这些输入中
secureTextEntry
属性),我会收到电子邮件建议。
Why is there a conflict between these properties and how can I fix it?为什么这些属性之间存在冲突,我该如何解决?
React Native version: 0.63.4 React Native 版本:0.63.4
I end up maintaining a state for secureTextEntry
and making true onFocus
and false onBlur
.我最终维护了
secureTextEntry
的状态并设置了 true onFocus
和 false onBlur
。
const [thisSecureTextEntry, setThisSecureTextEntry] = useState(false);
const updateThisSecureTextEntry = (value: boolean) => {
if(securedTextEntry) {
setThisSecureTextEntry(value);
}
}
<TextInput
onFocus={() => updateThisSecureTextEntry(true)}
onBlur={() => updateThisSecureTextEntry(false)}
style={styles.text}
placeholder={placeholder}
placeholderTextColor={PLACEHOLDER_GRAY}
onChangeText={onTextChange}
keyboardType={keyboardType}
autoCapitalize={isAutoCapitalizeDisabled}
secureTextEntry={thisSecureTextEntry}
textContentType={textContentType}
/>
Suggestion by AbdulAzeem. AbdulAzeem 的建议。 You can also find the same suggestion here: https://github.com/facebook/react-native/issues/27586#issuecomment-580739397
您还可以在这里找到相同的建议: https ://github.com/facebook/react-native/issues/27586#issuecomment-580739397
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.