style: rename getDerivedStateFromProps to getDerivedState

pull/2284/head
tangjinzhou 2020-05-16 22:18:53 +08:00
parent 04b7d3a934
commit af69044a67
4 changed files with 13 additions and 13 deletions

View File

@ -161,7 +161,7 @@ const Select = {
return {
...state,
_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: {
__propsSymbol__() {
Object.assign(this.$data, this.getDerivedStateFromProps(getOptionProps(this), this.$data));
Object.assign(this.$data, this.getDerivedState(getOptionProps(this), this.$data));
},
'$data._inputValue'(val) {
this.$data._mirrorInputValue = val;
@ -210,7 +210,7 @@ const Select = {
}
},
methods: {
getDerivedStateFromProps(nextProps, prevState) {
getDerivedState(nextProps, prevState) {
const optionsInfo = prevState._skipBuildOptionsInfo
? prevState._optionsInfo
: this.getOptionsInfoFromProps(nextProps, prevState);

View File

@ -9,7 +9,7 @@ import { createRef } from '../util';
// onTreeNodeSelect: PropTypes.func.isRequired,
// onTreeNodeCheck: PropTypes.func.isRequired,
// }
function getDerivedStateFromProps(nextProps, prevState) {
function getDerivedState(nextProps, prevState) {
const {
_prevProps: prevProps = {},
_loadedKeys: loadedKeys,
@ -106,7 +106,7 @@ const BasePopup = {
},
watch: {
__propsSymbol__() {
const state = getDerivedStateFromProps(this.$props, this.$data);
const state = getDerivedState(this.$props, this.$data);
this.setState(state);
},
},
@ -124,14 +124,14 @@ const BasePopup = {
const state = {
_keyList: [],
_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: [],
_loadedKeys: [],
_prevProps: {},
};
return {
...state,
...getDerivedStateFromProps(this.$props, state),
...getDerivedState(this.$props, state),
};
},
methods: {

View File

@ -187,7 +187,7 @@ const Select = {
_treeNodes: undefined,
_filteredTreeNodes: undefined,
};
const newState = this.getDerivedStateFromProps(this.$props, state);
const newState = this.getDerivedState(this.$props, state);
return {
...state,
...newState,
@ -215,7 +215,7 @@ const Select = {
watch: {
...getWatch(['treeData', 'defaultValue', 'value']),
__propsSymbol__() {
const state = this.getDerivedStateFromProps(this.$props, this.$data);
const state = this.getDerivedState(this.$props, this.$data);
this.setState(state);
this.needSyncKeys = {};
},
@ -266,7 +266,7 @@ const Select = {
},
methods: {
getDerivedStateFromProps(nextProps, prevState) {
getDerivedState(nextProps, prevState) {
const h = this.$createElement;
const { _prevProps: prevProps = {} } = prevState;
const {

View File

@ -128,7 +128,7 @@ const Tree = {
};
return {
...state,
...this.getDerivedStateFromProps(getOptionProps(this), state),
...this.getDerivedState(getOptionProps(this), state),
};
},
provide() {
@ -148,13 +148,13 @@ const Tree = {
'loadedKeys',
]),
__propsSymbol__() {
this.setState(this.getDerivedStateFromProps(getOptionProps(this), this.$data));
this.setState(this.getDerivedState(getOptionProps(this), this.$data));
this.needSyncKeys = {};
},
},
methods: {
getDerivedStateFromProps(props, prevState) {
getDerivedState(props, prevState) {
const { _prevProps } = prevState;
const newState = {
_prevProps: { ...props },