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

296
Visualizações
Difference between Ant Design form.setFieldsValue and initialValues prop

As the title states. What is the difference between the two?

1.

import { Form } from 'antd';

const Components = () => {
  const [form] = Form.useForm();
  form.setFieldsValue({ ... });

  return (
    <Form form={form}>
      ...
    </Form>
  );
}
import { Form } from 'antd';

const Components = () => {
  return (
    <Form initialValues={{ ... }}>
      ...
    </Form>
  );
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

setFieldValues is good for on-demand setting of values. For example, if there was a "Default" button on your form that sets all the values back to some default. The problem with using setFieldValues on form, is that if you are passing props down that change or a function prop, the setFieldValues will be called over and over again when props refresh in the app. This can cause the form to reset to the values in setFieldValues randomly while the user has the form up.

initialValues only sets the initial values when the form initializes and does not have the same issue as stated above, so its ideal for setting up a form with initial values while having props that may be refreshing or changing. This causes your form to behave well and not change on the user until the form is destroyed.

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