React Native: Получение “недопустимого вызова” в APK-версии приложения React Native

#javascript #android #react-native

Вопрос:

**Когда я нажимаю, чтобы написать адрес электронной почты и номер телефона в поле ввода, приложение выпуска завершает работу

Я получаю эту ошибку при использовании крючка useState. просматриваю документы react native для справки, но все еще получаю эту ошибку.

Код здесь

const initialState = { Идентификатор пользователя: «, Электронная почта: «, адрес электронной почты: false, текст электронной почты: «, загрузка: false, ismailsent: false, isotpsent: false }; const [поле ввода, setInputField] = useState(начальное состояние); const toast = useToast();

   const inputsHandler = (e, type) => {

    if (type === "Email") {
      console.log("E data", e);
      setInputField((inputField) => ({
        ...inputField,
        Email: e,
        EmailErr: false,
        EmailErrText: "",
      }));
    }
  }

  const validation = (e) => {
    let IsValid = true;
    const { Email } = inputField;

    if (CommonConfig.isEmpty(Email)) {
      setInputField((inputField) => ({
        ...inputField,
        EmailErr: true,
        EmailErrText: "Email/Phone is required.",
      }));
      IsValid = false;

    } else if (!Email.match(CommonConfig.RegExp.EmailRegex) amp;amp; !Email.match(CommonConfig.RegExp.phoneRegExp)) {
      setInputField((inputField) => ({
        ...inputField,
        EmailErr: true,
        EmailErrText: "Please enter valid Email amp; Phone.",
      }));
      IsValid = false;
    } else {
      setInputField((inputField) => ({
        ...inputField,
        EmailErr: false,
        EmailErrText: "",
      }));
    }
    return IsValid;
  }


  const handleForgotPassword = () => {
    if (validation()) {
      setInputField((inputField) => ({
        ...inputField, loading: true,
      }));
      const data = {
        username_phone: inputField.Email,
      };
      console.log('data', data);
      
      fetch(URL, {
        method: 'POST',
        body: JSON.stringify(data),
        headers: {
          'Content-Type': 'application/json',
        },
      })
        .then(response => response.json())
        .then(res => {
          console.log("Response", res);
          //Hide Loader
          setInputField((inputField) => ({
            ...inputField, loading: false,
          }));
          if (res.Success === 1) {
            setInputField((inputField) => ({
              ...inputField, loading: false, ismailsent: true, isotpsent: false
            }));
            console.log("Mail sent to your registered email Id");
            navigation.navigate('LoginScreen');
          } else if (res.Success === 2) {
            AsyncStorage.setItem("passwordDataUID", res.Info.UserId);
            AsyncStorage.setItem("passwordDataUIDPN", res.Info.PhoneNumber);
            console.log("OTP Sent to your Registered Number");
            setInputField((inputField) => ({
              ...inputField, loading: false, ismailsent: false, isotpsent: true
            }));
            // if (inputField.isotpsent === true) {
            AsyncStorage.setItem("OtpAccess", JSON.stringify(true));
            navigation.navigate('OTPVerifyScreen', {
              isPhoneVerification: true, propsData: res.Info,
            });
            // }
          } else {
            setInputField((inputField) => ({
              ...inputField, loading: false, isotpsent: false, ismailsent: false
            }));
            console.log("Invalid mobile number or email id");
          }
        })
        .catch(error => {
          //Hide Loader
          setInputField((inputField) => ({
            ...inputField, loading: false
          }));
          console.log("Error: ", error);
          console.log("Something went wrong");
        });
    }
  };

  const { Email, EmailErr, EmailErrText, loading } = inputField




<Input
                style={styles.formInput}
                InputLeftElement={
                  <Icon
                    as={<MaterialIcons name="email" />}
                    size={5}
                    ml="2"
                    color="black"
                  />
                }
                value={Email}
                onChangeText={(e) => inputsHandler(e, "Email")}
                variant="underlined"
                placeholder="Email/Phone"
              />