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

112
Visualizações
re-render when state in another component changes

i have 2 files setter.jsx and active.jsx

setter.jsx

function SetState() {
  const [State, setState] = useState("default state");

  const setter = (options) => {
    setState(options);
  };

  const getter = () => {
    return State;
  };

  return { State, setter, getter };
}

somewhere in setter.jsx

const {setter} = SetState();
setter(options);

in active.jsx

import {SetState} from "setter";
const {State} = SetState();
return {State};

when the setter() is called in setter.jsx, the state is changed but then active.jsx keeps returning the default state. how can active.jsx re-render and return the new value whenever setter is called in setter.jsx?

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