react-highcharts
react-highcharts copied to clipboard
Remove isPureConfig and make ReactHighcharts a PureComponent
Hi,
I think it might make sense to remove isPureConfig since it's very unreliable. Specifically, it operates on this comparison:
`if (nextProps.neverReflow || (nextProps.isPureConfig && this.props.config === nextProps.config)) {
...
The Strict Equality Comparison (===) will only be true if the two objects are the same. So in popular state managers like Redux, where the next state is a complete copy of the new state, this will never be true.
This can be very confusing to beginners, which is why there are a lot of other (closed) issues about isPureConfig.
Instead, it might makes sense to make ReactHighcharts a PureComponent. It seems that ReactHighcharts's render is only affected by props/state, so it should be safe to do this.
Alternatively, if there's a good reason to not make ReactHighcharts a PureComponent, it may make sense to make a "PureReactHighchart" component that is a PureComponent.
Thanks for your input, @rclmenezes, this all makes sense, I'm happy to accepts a PR for that if anyone volunteers.
Ok, keeping this open, so it's visible.
@kirjs I'll look into making a PureReactHighcharts component.
@kirjs How far did you take a look?