Home > other >  React Native, why secureTextEntry not working?
React Native, why secureTextEntry not working?

Time:03-22

Why is my secureTextEntry not working ? Here is my code:

export default function App() {
  const { t } = useTranslation();
  const [value, setValue] = useState('');
  return (
    <View style={s.container}>
      <Input value='' placeholder='Passwort' style={[InputStyles.normal, s.inputMargin]} />
      <Input value={value} onChangeText={(e) => setValue(e)} placeholder='E-Mail' style={InputStyles.normal_icon} icon={<AntDesign name="stepforward" size={24} color="black" />} multiline secureTextEntry={true} keyboardType='default' />
    </View>
  );
}

CodePudding user response:

secureTextEntry does not work with multiline. Here is what React Native documentation says:

secureTextEntry

If true, the text input obscures the text entered so that sensitive text like passwords stay secure. The default value is false. Does not work with multiline={true}.

In order to have it works, remove multiline propriety, like so:

export default function App() {
  const { t } = useTranslation();
  const [value, setValue] = useState('');
  return (
    <View style={s.container}>
      <Input value='' placeholder='Passwort' style={[InputStyles.normal, s.inputMargin]} />
      <Input value={value} onChangeText={(e) => setValue(e)} placeholder='E-Mail' style={InputStyles.normal_icon} icon={<AntDesign name="stepforward" size={24} color="black" />} secureTextEntry={true} keyboardType='default' />
    </View>
  );
}
  • Related