Removed componentWillUpdate

This commit is contained in:
orangemug
2018-08-06 22:24:13 +01:00
parent c5ea9494df
commit 1aa90bef37
7 changed files with 52 additions and 48 deletions

View File

@@ -29,10 +29,10 @@ class JSONEditor extends React.Component {
}
}
UNSAFE_componentWillReceiveProps(nextProps) {
this.setState({
code: JSON.stringify(nextProps.layer, null, 2)
})
static getDerivedStateFromProps(props, state) {
return {
code: JSON.stringify(props.layer, null, 2)
};
}
shouldComponentUpdate(nextProps, nextState) {

View File

@@ -79,18 +79,18 @@ export default class LayerEditor extends React.Component {
this.state = { editorGroups }
}
UNSAFE_componentWillReceiveProps(nextProps) {
const additionalGroups = { ...this.state.editorGroups }
static getDerivedStateFromProps(props, state) {
const additionalGroups = { ...state.editorGroups }
layout[nextProps.layer.type].groups.forEach(group => {
layout[props.layer.type].groups.forEach(group => {
if(!(group.title in additionalGroups)) {
additionalGroups[group.title] = true
}
})
this.setState({
return {
editorGroups: additionalGroups
})
};
}
getChildContext () {