I have a weird problem with react native 0.62, in onChangeText, I try to call 2 functions setData and checkEmailSyntax. I don't know why but only the first function executes. I have seen similar questions, but nothing works.
Also, I have this same problem with context. Context returns function like logout, setUser, and so on when I try to execute these functions one after another in useEffect only the last function is called.
Do you think this is a react native version problem? or it is my fault.
Ok, @Nestoro solved this mistary, the checkEmail is coping old state without a new email so the email state is empty. New question is can I mutate a wrongEmailSyntax state? or I have to use a useEffect and fire it every time when email changes?
<TextInput
style={styles.inputText}
placeholder="e-mail"
autoCompleteType="email"
onChangeText={text => {
setData({ ...data, input_email: text });
checkEmailSyntax(text);
}}
autoCapitalize="none"
placeholderTextColor="grey"
/>
const checkEmailSyntax = (inputVal) => {
if (inputVal.includes('@') && inputVal.includes('.')) {
setData({ ...data, wrongEmailSyntax: false });
} else {
setData({ ...data, wrongEmailSyntax: true });
}
};
const [data, setData] = useState({
input_email: '',
input_password: '',
wrongEmailSyntax: false,
});