Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

145
Visualizações
React native formik triggers validation on next visit

I have a weird problem with my react-native form (I am using formik library). I have a form which has one input with autofocus, user reads barcode with external reader and app shows him some data about the product. Everything works fine on the first try, but when the user wanna read another code, validation is triggered after navigation which causes the input to lose focus, so the user needs to manualy select it and then use the reader. My code looks like this, its simple form with one input and action on submit. Validation checks if the field is empty, but I need it only after submit not after navigation.

 const handleSubmit = (values, {resetForm}) => {
    if (nextPage === pages.TOKLIS19) {
      dispatch(fetchPaletaSklad.request({ carovyKod: values.carovyKod, kodUzivatele, nextPage }));
    } else {
      dispatch(fetchPaleta.request({ carovyKod: values.carovyKod, nextPage }));
    }
    resetForm();
  }

<Formik
      initialValues={{carovyKod: ''}}
      onSubmit={onSubmit}
      validate={validateCarovyKod}>
      {({handleSubmit, handleChange, values, ...rest}) => (
        <Fragment>
          <Text style={styles.text}>{i18n.paletaForm.carovyKod}: </Text>
          <Input autoFocus values={values} name="carovyKod" handleChange={(name) => {onChange(name, values); return handleChange(name);} }
          keyboardType={Platform.OS == 'android' ? "phone-pad" : "number-pad"}
          {...rest} />

          <Button
            style={styles.button}
            title={i18n.paletaForm.btnOk}
            onPress={handleSubmit}
          />
          
          <Button
          title={i18n.common.back}
          onPress={onBack()}
        />
        </Fragment>
      )}
    </Formik>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda