From cf45c040690060283cac84cf09dd5b52a15c48ca Mon Sep 17 00:00:00 2001 From: Peter Richardson Date: Mon, 12 Nov 2018 20:47:24 -0800 Subject: [PATCH] add shouldComponentUpdate checks for differences in props and state - addresses https://github.com/maputnik/editor/issues/467 --- src/components/map/MapboxGlMap.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/map/MapboxGlMap.jsx b/src/components/map/MapboxGlMap.jsx index dd4885f..0a482f9 100644 --- a/src/components/map/MapboxGlMap.jsx +++ b/src/components/map/MapboxGlMap.jsx @@ -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;