From 4ba71c8bd5781ae06ceb31a4be47c550508e7fca Mon Sep 17 00:00:00 2001 From: pathmapper Date: Thu, 20 Jun 2019 09:52:54 +0200 Subject: [PATCH 1/3] Remove UNSAFE_componentWillUpdate --- src/components/modals/AddModal.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/modals/AddModal.jsx b/src/components/modals/AddModal.jsx index 0cdac515..abf1fb74 100644 --- a/src/components/modals/AddModal.jsx +++ b/src/components/modals/AddModal.jsx @@ -53,7 +53,7 @@ class AddModal extends React.Component { } } - UNSAFE_componentWillUpdate(nextProps, nextState) { + shouldComponentUpdate(nextProps, nextState) { // Check if source is valid for new type const oldType = this.state.type; const newType = nextState.type; @@ -75,6 +75,7 @@ class AddModal extends React.Component { source: "" }); } + return true; } getLayersForSource(source) { From 0e7bd98485c731e29ae9db1e56159649969a40e4 Mon Sep 17 00:00:00 2001 From: pathmapper Date: Sun, 23 Jun 2019 09:53:52 +0200 Subject: [PATCH 2/3] Use componentDidUpdate --- src/components/modals/AddModal.jsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/modals/AddModal.jsx b/src/components/modals/AddModal.jsx index abf1fb74..248994bc 100644 --- a/src/components/modals/AddModal.jsx +++ b/src/components/modals/AddModal.jsx @@ -53,10 +53,10 @@ class AddModal extends React.Component { } } - shouldComponentUpdate(nextProps, nextState) { + componentDidUpdate(prevProps, prevState) { // Check if source is valid for new type - const oldType = this.state.type; - const newType = nextState.type; + const oldType = prevState.type; + const newType = this.state.type; const availableSourcesOld = this.getSources(oldType); const availableSourcesNew = this.getSources(newType); @@ -64,18 +64,17 @@ class AddModal extends React.Component { if( // Type has changed oldType !== newType - && this.state.source !== "" + && prevState.source !== "" // Was a valid source previously - && availableSourcesOld.indexOf(this.state.source) > -1 + && availableSourcesOld.indexOf(prevState.source) > -1 // And is not a valid source now - && availableSourcesNew.indexOf(nextState.source) < 0 + && availableSourcesNew.indexOf(this.state.source) < 0 ) { // Clear the source this.setState({ source: "" }); } - return true; } getLayersForSource(source) { From 0500172d4200124d23bc08c43de4c8def673e02c Mon Sep 17 00:00:00 2001 From: pathmapper Date: Sun, 23 Jun 2019 09:55:32 +0200 Subject: [PATCH 3/3] Update layer types --- src/components/modals/AddModal.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/modals/AddModal.jsx b/src/components/modals/AddModal.jsx index 248994bc..6594e7a0 100644 --- a/src/components/modals/AddModal.jsx +++ b/src/components/modals/AddModal.jsx @@ -91,10 +91,19 @@ class AddModal extends React.Component { "line", "symbol", "circle", - "fill-extrusion" + "fill-extrusion", + "heatmap" ], raster: [ "raster" + ], + geojson: [ + "fill", + "line", + "symbol", + "circle", + "fill-extrusion", + "heatmap" ] }