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

261
Visualizações
Conditional Operator for React Components, not updating

I currently have 2 Components that work conditionally, but i would like it to update and change when the createdSavingsGoal state array is greater than 0 (i.e Not empty)

Then it shows a List.. When its empty it shows a Form that allows me to Post to that array. Currently i have to refresh that page but i would just like it to work. automatically

Im not brilliant with State so if im doing something obvious.

this.state = {
  createdSavingsGoal: "",
};

..

render() {
const { createdSavingsGoal } = this.state;
if (createdSavingsGoal.length > 0) {
  return <ViewSavingsGoal />;
} else {
  return <CreateSavingsGoal />;
}
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