add shouldComponentUpdate

checks for differences in props and state - addresses https://github.com/maputnik/editor/issues/467
This commit is contained in:
Peter Richardson 2018-11-12 20:47:24 -08:00
parent 05d149bcfa
commit cf45c04069

View file

@ -97,6 +97,16 @@ export default class MapboxGlMap extends React.Component {
}
}
shouldComponentUpdate(nextProps, nextState) {
let should = false;
try {
should = JSON.stringify(this.props) !== JSON.stringify(nextProps) || JSON.stringify(this.state) !== JSON.stringify(nextState);
} catch(e) {
// no biggie, carry on
}
return should;
}
componentDidUpdate(prevProps) {
if(!IS_SUPPORTED) return;