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

325
Visualizações
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 Respostas
Responde à pergunta

0

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

OR

onChange={handleChange}
about 4 years ago · Juan Pablo Isaza Relatório

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 Relatório
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