React Warning: Cannot update a component from inside the function body of a different component

前端 未结 10 1126
攒了一身酷
攒了一身酷 2021-01-01 12:24

I am using Redux with Class Components in React. Having the below two states in Redux store.

{ spinner: false, refresh: false }

In Parent C

10条回答
  •  萌比男神i
    2021-01-01 12:44

    If you want to invoke some function passed as props automatically from child component then best place is componentDidMount lifecycle methods in case of class components or useEffect hooks in case of functional components as at this point component is fully created and also mounted.

提交回复
热议问题