News for hackers. Stuff that matters.
Re:Why-did-you-update – Warnings about unnecessary React upd... by coltonv on Wednesday April 19, 2017 @01:49PM (#14149943)
So recalculating the virtual DOM is fast, but it does have a cost. The easy way to combat this cost is to realize that if you're doing things right and using pure functions, you'll get the exact same UI if you're state hasn't changed. So if you know the state that feeds into a certain component hasn't changed, you can get much better performance.

This library basically encourages you to use React's "PureComponent", which automatically does that calculation to see if the props have changed for you, thus giving you a huge speedup since only the components that need to update will.

Re:Why-did-you-update – Warnings about unnecessary React upd... by Kiro on Wednesday April 19, 2017 @02:29PM (#14150378)
Why isn't PureComponent just default?
Re:Why-did-you-update – Warnings about unnecessary React upd... by acemarke on Wednesday April 19, 2017 @02:34PM (#14150434)
A few reasons:

- PureComponent was only added relatively recently.

- While shallow equality comparisons are relatively fast compared to deep equality comparisons, they still burn CPU. There's also a number of reasons why props could have changed, such as object literals being declared in the parent's `render` method, or the component receiving other components via `props.children`. In those cases, the "pure" comparison will fail every time, and be useless.

- There is no "default" per se. Application components explicitly extend a React component base class - either React.Component, or React.PureComponent.

Re:Why-did-you-update – Warnings about unnecessary React upd... by vinnymac on Wednesday April 19, 2017 @02:54PM (#14150643)
It is not a bullet proof solution. It has its use cases, but a couple pitfalls as well. Using PureComponent as a parent to many Component classes is generally not a good idea. If a child depends on a change from `this.context` it will not re-render unless the PureComponent declares `contextTypes`.

https://github.com/facebook/react/issues/2517