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

96
Visualizações
Best way to pass mutate state in children components then use it in the parent component and use memoization

I have a page that is compiled with 3 form components I want the parent page to have the state and pass through the state to child components then I want to mutate the state in the forms and then use them in the parent component I currently doing it in a way similar to as shown below but I am not sure if this is the best approach to handle state in child components is there a better way ? Also I want to memoize the form components with react.memo to prevent them from re-rendering unless the props have changed. Any help would be much appreciated


const [form1, setform1] = useState<boolean>(false);
const [Form2, setform2] = useState<string>("");
const [form3, setForm3] = useState({});
<form1 form1={form1} setfrom1={setform1} otherProps={otherProps} />
<form2 form2={form2} setfrom2={setform2} otherProps={otherProps} />
<form3 form3={form3} setfrom1={setform3} otherProps={otherProps}/>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Also, you can use Context API. If your other props are similar for your forms it will be the best solution for your.

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