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

144
Vistas
React-hook-form reset submit button disabled state after submit?

I have a form build with react-hook-form v7 and there is one thing that I can not make it work. The submit button is disabled until some field in the form gets a value, then when I click on the submit button it gets disabled to avoid submitting the form twice by mistake. With the form submitted and the button disabled if I make a change in some field the submit button remains disabled and that is what I can't make it work, I want the button gets enabled if I make changes in the form.

This is the code for the form:

const {
        control,
        handleSubmit, reset,
        formState: { errors, isDirty, isSubmitted, },
    } = useForm<ISearchListFormFields>({
        defaultValues: {
            chiefCategory: null,
        },
        mode: 'onChange'
    });
    
 <form onSubmit={handleSubmit(onSubmit)}>
    <div>
      <Label className='select-label'>Chefskategori</Label>
          <Controller
              control={control}
              name='chiefCategory'
              render={({ field: { onChange, value, ref } }) => (
                  <Select
                    inputRef={ref}
                    className='react-select-container authoritySelect'
                    classNamePrefix='react-select'
                    placeholder='Välj'
                    options={categoryList}
                    value={
                      categoryList.find((c) => c.value === value)
                        ? categoryList.find((c) => c.value === value)
                        : null
                    }
                    onChange={(val) => {onChange(val.value);}}
                  />
              )}
           />
    </div>
    <div>
      <RKPrimaryButton
        text='Search'
        type='submit'
        disabled={!isDirty || isSubmitted}
      />
    </div>
 </form>

Thanks for any help!

about 4 years ago · Juan Pablo Isaza
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