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

129
Visualizações
Cannot post data to the API using Picker with Formik

I'm trying to post data to the API using Picker and Formik, but in Formik it returns an empty value from Picker.

The problem is detected in the Picker, in onValueChange.

NOTE: In the Picker, get data successfully.

<Formik
   initialValues={{ article: '', type: '' }}
    onSubmit={(values, { setSubmitting }) => {
        if(values.article == '') {
            handleMessage('The field is mandatory');
            setSubmitting(false);
        } else {
            console.log(values);
            handleCreateItem(values, setSubmitting);
        }
    }}
>
    {({handleChange, handleBlur, handleSubmit, values, isSubmitting}) => (
        <CFormArea>
            <TextInput
                placeholder="Article"
                placeholderTextColor={text}
                onChangeText={handleChange('article')}
                onBlur={handleBlur('article')}
                value={values.article}
            />
            <CLabel>Type</CLabel>
            <Picker
                style={{color:'white'}}
                selectedValue={values.type} 
                onValueChange={(itemValue) => handleChange('type', itemValue)}
            >
            {
                getType.map((types, index) => {
                    return <Picker.Item key={index} label={types.material} value={types.id}  /> 
                })
            }
            </Picker>
            {!isSubmitting && (
                <Button onPress={handleSubmit}>
                    <TextButton> Create Item </TextButton>
                </Button>
            )}
        </CFormArea>
    )}
</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