I'm new to React-Native and looking for a simple, straightforward way to toggle visibility of elements. Why won't this code of mine show/hide the icon? It's a simple useState and useEffect right?
const [isDisabled, setIsDisabled] = React.useState('opacity:0')
React.useEffect(() => {
const emailIsValid = regexEmail.test(email)
console.log(emailIsValid)
if(emailIsValid) {
setIsDisabled('opacity:0')
} else {
setIsDisabled('opacity:100')
}
}, [email])
return (
<View style={styles.container}>
<TextInput
style={styles.textInput}
placeholder="Email address"
value = {email}
onChangeText={text=>setEmail(text)} />
<EvilIcons name="exclamation" size={24} color="orange" style={{isDisabled}}/> /*this one!*/
<TextInput
style={styles.textInput}
placeholder="Password"
value={password}
onChangeText={text=>setPassword(text)}
secureTextEntry />
<TextInput
style={styles.textInput}
placeholder="Confirm password"
value={confirmPassword}
onChangeText={text=>setConfirmPassword(text)}
secureTextEntry />
<Button
disabled={submitDisabled}
style={styles.buttonLogin}
title='Register'
onPress={submitRegister} />
</View>
)