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

191
Visualizações
React cannot update during an existing state transition (such as within render ) functional component

I am dealing with two components and one store.Components are Child and Parent,Store is store. Parent when rendering, make the child component up and parent listens to store.Now I want to update the state of variable in Store, by exposing a method from Store. The parent pass this method as a call back to child. Child has a dialog box, and if user closes/dismiss that dialog box, the clearStoreInfo() should be called, which is passed by parent to child. But when i do so, I get error

React cannot update during an existing state transition (such as within render ) functional component

Store looks as :

class Stores {
........
........
........
 @action.bound
    clearStoreInfo = () => {
        console.log(" clear info");
    }

}

Parent Component:

import Store ........
class InfoContainer extends React.Component {

 return (
            <div id={"info"} className={"container"}>
                <ButtonPanel store={Store} />
                
            </div>
}

const ButtonPanel = (props) => {
return (
.....
.....
<div>
            <ChildComponent clearStoreInfo={props.store.clearStoreInfo}/>
</div>
......
            }

class ChildComponent extends React.Component {

render(){
 const {clearStoreInfo} = this.props;

return (
////if -else ladder

clearStoreInfo();  // warning line.
<Dialog.......
onClose={clearStoreInfo}

/>
)
}

//Because of warning, the dialog box dont come. If i remove clearStoreInfo(), then dialog box works fine.

Is there any easy workaround given these components and store?

The wiring works fine, because I can see console log,based on if-else ladder, but its just the warning is messing things up internally.onClose is able to call the clearStoreInfo perfectally, but its when I manually call it, I am getting a warning.

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