Lucifier129 / react-lite

An implementation of React v15.x that optimizes for small script size
MIT License
1.73k stars 100 forks source link

history.push() inside componentWillReceiveProps breaks destroyVcomponent() #109

Closed oxpa closed 7 years ago

oxpa commented 7 years ago

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.

Lucifier129 commented 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;)

oxpa commented 7 years ago

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?

Lucifier129 commented 7 years ago

Yes, PR is welcome, I am looking forward!