react-highcharts icon indicating copy to clipboard operation
react-highcharts copied to clipboard

Remove isPureConfig and make ReactHighcharts a PureComponent

Open rclmenezes opened this issue 8 years ago • 4 comments

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.

rclmenezes avatar Dec 08 '16 22:12 rclmenezes

Thanks for your input, @rclmenezes, this all makes sense, I'm happy to accepts a PR for that if anyone volunteers.

kirjs avatar Mar 18 '17 16:03 kirjs

Ok, keeping this open, so it's visible.

kirjs avatar Mar 18 '17 16:03 kirjs

@kirjs I'll look into making a PureReactHighcharts component.

czarnega avatar Jun 16 '17 18:06 czarnega

@kirjs How far did you take a look?

mobilutz avatar Mar 01 '18 15:03 mobilutz