style: rename getDerivedStateFromProps to getDerivedState
parent
04b7d3a934
commit
af69044a67
|
@ -161,7 +161,7 @@ const Select = {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
_mirrorInputValue: state._inputValue, // https://github.com/vueComponent/ant-design-vue/issues/1458
|
_mirrorInputValue: state._inputValue, // https://github.com/vueComponent/ant-design-vue/issues/1458
|
||||||
...this.getDerivedStateFromProps(props, state),
|
...this.getDerivedState(props, state),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ const Select = {
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
__propsSymbol__() {
|
__propsSymbol__() {
|
||||||
Object.assign(this.$data, this.getDerivedStateFromProps(getOptionProps(this), this.$data));
|
Object.assign(this.$data, this.getDerivedState(getOptionProps(this), this.$data));
|
||||||
},
|
},
|
||||||
'$data._inputValue'(val) {
|
'$data._inputValue'(val) {
|
||||||
this.$data._mirrorInputValue = val;
|
this.$data._mirrorInputValue = val;
|
||||||
|
@ -210,7 +210,7 @@ const Select = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getDerivedStateFromProps(nextProps, prevState) {
|
getDerivedState(nextProps, prevState) {
|
||||||
const optionsInfo = prevState._skipBuildOptionsInfo
|
const optionsInfo = prevState._skipBuildOptionsInfo
|
||||||
? prevState._optionsInfo
|
? prevState._optionsInfo
|
||||||
: this.getOptionsInfoFromProps(nextProps, prevState);
|
: this.getOptionsInfoFromProps(nextProps, prevState);
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { createRef } from '../util';
|
||||||
// onTreeNodeSelect: PropTypes.func.isRequired,
|
// onTreeNodeSelect: PropTypes.func.isRequired,
|
||||||
// onTreeNodeCheck: PropTypes.func.isRequired,
|
// onTreeNodeCheck: PropTypes.func.isRequired,
|
||||||
// }
|
// }
|
||||||
function getDerivedStateFromProps(nextProps, prevState) {
|
function getDerivedState(nextProps, prevState) {
|
||||||
const {
|
const {
|
||||||
_prevProps: prevProps = {},
|
_prevProps: prevProps = {},
|
||||||
_loadedKeys: loadedKeys,
|
_loadedKeys: loadedKeys,
|
||||||
|
@ -106,7 +106,7 @@ const BasePopup = {
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
__propsSymbol__() {
|
__propsSymbol__() {
|
||||||
const state = getDerivedStateFromProps(this.$props, this.$data);
|
const state = getDerivedState(this.$props, this.$data);
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -124,14 +124,14 @@ const BasePopup = {
|
||||||
const state = {
|
const state = {
|
||||||
_keyList: [],
|
_keyList: [],
|
||||||
_expandedKeyList: expandedKeyList,
|
_expandedKeyList: expandedKeyList,
|
||||||
// Cache `expandedKeyList` when tree is in filter. This is used in `getDerivedStateFromProps`
|
// Cache `expandedKeyList` when tree is in filter. This is used in `getDerivedState`
|
||||||
_cachedExpandedKeyList: [],
|
_cachedExpandedKeyList: [],
|
||||||
_loadedKeys: [],
|
_loadedKeys: [],
|
||||||
_prevProps: {},
|
_prevProps: {},
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
...getDerivedStateFromProps(this.$props, state),
|
...getDerivedState(this.$props, state),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -187,7 +187,7 @@ const Select = {
|
||||||
_treeNodes: undefined,
|
_treeNodes: undefined,
|
||||||
_filteredTreeNodes: undefined,
|
_filteredTreeNodes: undefined,
|
||||||
};
|
};
|
||||||
const newState = this.getDerivedStateFromProps(this.$props, state);
|
const newState = this.getDerivedState(this.$props, state);
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
...newState,
|
...newState,
|
||||||
|
@ -215,7 +215,7 @@ const Select = {
|
||||||
watch: {
|
watch: {
|
||||||
...getWatch(['treeData', 'defaultValue', 'value']),
|
...getWatch(['treeData', 'defaultValue', 'value']),
|
||||||
__propsSymbol__() {
|
__propsSymbol__() {
|
||||||
const state = this.getDerivedStateFromProps(this.$props, this.$data);
|
const state = this.getDerivedState(this.$props, this.$data);
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
this.needSyncKeys = {};
|
this.needSyncKeys = {};
|
||||||
},
|
},
|
||||||
|
@ -266,7 +266,7 @@ const Select = {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
getDerivedStateFromProps(nextProps, prevState) {
|
getDerivedState(nextProps, prevState) {
|
||||||
const h = this.$createElement;
|
const h = this.$createElement;
|
||||||
const { _prevProps: prevProps = {} } = prevState;
|
const { _prevProps: prevProps = {} } = prevState;
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -128,7 +128,7 @@ const Tree = {
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
...this.getDerivedStateFromProps(getOptionProps(this), state),
|
...this.getDerivedState(getOptionProps(this), state),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
provide() {
|
provide() {
|
||||||
|
@ -148,13 +148,13 @@ const Tree = {
|
||||||
'loadedKeys',
|
'loadedKeys',
|
||||||
]),
|
]),
|
||||||
__propsSymbol__() {
|
__propsSymbol__() {
|
||||||
this.setState(this.getDerivedStateFromProps(getOptionProps(this), this.$data));
|
this.setState(this.getDerivedState(getOptionProps(this), this.$data));
|
||||||
this.needSyncKeys = {};
|
this.needSyncKeys = {};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
getDerivedStateFromProps(props, prevState) {
|
getDerivedState(props, prevState) {
|
||||||
const { _prevProps } = prevState;
|
const { _prevProps } = prevState;
|
||||||
const newState = {
|
const newState = {
|
||||||
_prevProps: { ...props },
|
_prevProps: { ...props },
|
||||||
|
|
Loading…
Reference in New Issue