zesik / react-splitter-layout

A simple split layout for React and modern browsers. https://zesik.com/react-splitter-layout
MIT License
422 stars 128 forks source link

Optimized mouse up listener #31

Closed gorhawk closed 5 years ago

zesik commented 5 years ago

Hi, why do we need this? If resizing is false before, there shouldn't be any re-rendering, right?

gorhawk commented 5 years ago

If you mean a DOM change by rendering, you are right. But the default implementation of shouldComponentUpdate just returns true. That means the lifecycle methods get called and eventually (most likely) React decides there should be no DOM change. You can help out React by not calling setState with the same state.

gorhawk commented 5 years ago

Yeah, found it in the docs: https://reactjs.org/docs/react-component.html#setstate

Sorry, I should've provided a description.

Edit: Oh, and it seems the React docs should also be updated too. In v16, you can return null from a setState callback. That's what I did in this commit. https://reactjs.org/blog/2017/09/26/react-v16.0.html

zesik commented 5 years ago

Oh, you're talking about the life cycle methods.

Will merge it. Thanks for contribution.

gorhawk commented 5 years ago

Yes, including render :D