Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

324
Vistas
method is not getting called on onChange event in formik react

I have to call below method using formik

   const handleChange = async (e:any, values: any) => {
        alert(e.target.value);
        alert(values);
        alert('Method called');
    };

below is formik code.

 <Formik initialValues={formInitialSchema}
                    validationSchema={formValidationSchema}
                    onSubmit={handleSubmit}>
                    <Form>
                       
                            <div className="col-md-4">
                                <label htmlFor="protoColNo">Protocol No</label>
                                <Field
                                    id="protoColNo"
                                    className="form-control"
                                    name="protoColNo"
                                    placeholder="Enter the Protocol No"
                                />
                                <p className="text-danger">
                                    <ErrorMessage name="protoColNo" />
                                </p>
                            </div>

                            <div className="col-md-4">
                                <label htmlFor="activerequests">Active Requests</label>
                                <select
                                name="activeRequest"
                                style={{ display: 'block' }}
                                onChange= {(e)=>handleChange}>
                                <option value="No"  >No </option>
                                <option value="Yes"  >Yes</option>
                                 <option value="All" selected>All </option>          
                            </select>

                                <p className="text-danger">
                                    <ErrorMessage name="activerequests" />
                                </p>
                            </div>
                        </div>
                    </Form>
                </Formik>
  

I have one input filed and one drop down. As soon as user change the value of drop down I need to call handleChange method with the value of input filed and list. but method is not getting called. I dont know what wrong I am doing?

can you please help me with the same?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

onChange= {(e)=>handleChange(e)}> //you forgot to call the handleChange

OR

onChange={handleChange}
about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to call the anonymous function inside the onChange event.

Use the following code :

onChange= {(e)=>handleChange(e)}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda