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

145
Visualizações
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 à 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