mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-30 16:45:30 +01:00
Merge pull request #532 from pathmapper/fix_issue_471
Remove UNSAFE_componentWillUpdate
This commit is contained in:
commit
b5eb74fe20
1 changed files with 16 additions and 7 deletions
|
@ -53,10 +53,10 @@ class AddModal extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillUpdate(nextProps, nextState) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
// Check if source is valid for new type
|
// Check if source is valid for new type
|
||||||
const oldType = this.state.type;
|
const oldType = prevState.type;
|
||||||
const newType = nextState.type;
|
const newType = this.state.type;
|
||||||
|
|
||||||
const availableSourcesOld = this.getSources(oldType);
|
const availableSourcesOld = this.getSources(oldType);
|
||||||
const availableSourcesNew = this.getSources(newType);
|
const availableSourcesNew = this.getSources(newType);
|
||||||
|
@ -64,11 +64,11 @@ class AddModal extends React.Component {
|
||||||
if(
|
if(
|
||||||
// Type has changed
|
// Type has changed
|
||||||
oldType !== newType
|
oldType !== newType
|
||||||
&& this.state.source !== ""
|
&& prevState.source !== ""
|
||||||
// Was a valid source previously
|
// Was a valid source previously
|
||||||
&& availableSourcesOld.indexOf(this.state.source) > -1
|
&& availableSourcesOld.indexOf(prevState.source) > -1
|
||||||
// And is not a valid source now
|
// And is not a valid source now
|
||||||
&& availableSourcesNew.indexOf(nextState.source) < 0
|
&& availableSourcesNew.indexOf(this.state.source) < 0
|
||||||
) {
|
) {
|
||||||
// Clear the source
|
// Clear the source
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -91,10 +91,19 @@ class AddModal extends React.Component {
|
||||||
"line",
|
"line",
|
||||||
"symbol",
|
"symbol",
|
||||||
"circle",
|
"circle",
|
||||||
"fill-extrusion"
|
"fill-extrusion",
|
||||||
|
"heatmap"
|
||||||
],
|
],
|
||||||
raster: [
|
raster: [
|
||||||
"raster"
|
"raster"
|
||||||
|
],
|
||||||
|
geojson: [
|
||||||
|
"fill",
|
||||||
|
"line",
|
||||||
|
"symbol",
|
||||||
|
"circle",
|
||||||
|
"fill-extrusion",
|
||||||
|
"heatmap"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue