Closed oxpa closed 7 years ago
It is better to aviod re-rendering in life-cycle method such like componentWillMount
, componentWillUpdate
or componentWillReceiveProps
.
Put the re-render logic into componentDidMount
and componentDidUpdate
instead;)
Oh, by the way, run into the same issue with componentDidUpdate(): was dispatching a redux event and got into a cycle where a queue of components for update was only growing. And once again the same code was working with react.
I don't feel like these troubles worth patching the code but it looks like it's a good idea to make a note somewhere for react-lite + redux users. Do you wan't me to compose a PR with this?
Yes, PR is welcome, I am looking forward!
I'm using react-lite with redux-react, react-router and react-router-redux. If I use history.push('/whatever') inside componentWillReceiveProps() it works fine with react. If I use the same with react-lite i get an error: there is no matching 'uid' inside cache and therefore code fails.
I believe, that real trouble is inside updateVcomponent which calls 'componentWillReceiveProps'
Do you need an exact description and minimal buggy implementation? I moved history.push() into 'componentDidMount' and it works for me perfectly right now.