Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!