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

140
Visualizações
How to unmounting a component properly in React Canvas? Its working but gives me a ton of errors

The code is working how I want. The balls appear and then the seeds appear after disappearing the balls. Yet, if you check the console, there is like 1000 errors, when the disappearance of the ball happens.

I have tried to solve it two ways. Both have failed

  const ballsSetter = () =>{
    setBalls(true)
  }

  const seedsSetter = () =>{
    setBalls(false)
    setSeeds(true)
  }

  const timingOfLevel2 = () => {
    setTimeout(ballsSetter, 5000);
    setTimeout(seedsSetter, 15000);
    setTimeout(() => {console.log("the end")},20000);
  }

useEffect(()=>{
  timingOfLevel2()
},[])
  

const ifAttempt = () =>{
  if(balls){
    return  <>
    <EnemiesBallsReturn 
    enemyBall1Ref = {enemyBall1Ref}
    />
    </>
  } else if (seeds){
    return <>
     <EnemiesSeedsReturn 
    enemySeed1Ref = {enemySeed1Ref}
   /> 
    </>
  } 
}

and returning the ifAttempt function in the return

or

>  {balls?   <EnemiesBallsReturn enemyBall1Ref = {enemyBall1Ref}/>:null}
   {seeds? <EnemiesSeedsReturn enemySeed1Ref = {enemySeed1Ref}/>:null}

either way when the state of balls or seeds is false, it is returning null. and I'm not seeing anything but when it switches to seed it throws this error. basically stating it cant draw an undefined I understand that but it shouldn't be checking for anything bc its unmounted/null? I'm confused any help or direction would be greatly appreciated

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