From af69044a6792a3acd60eb7940b0da04083878865 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sat, 16 May 2020 22:18:53 +0800 Subject: [PATCH] style: rename getDerivedStateFromProps to getDerivedState --- components/vc-select/Select.jsx | 6 +++--- components/vc-tree-select/src/Base/BasePopup.jsx | 8 ++++---- components/vc-tree-select/src/Select.jsx | 6 +++--- components/vc-tree/src/Tree.jsx | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/vc-select/Select.jsx b/components/vc-select/Select.jsx index a97ecf1d3..754bd7d33 100644 --- a/components/vc-select/Select.jsx +++ b/components/vc-select/Select.jsx @@ -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); diff --git a/components/vc-tree-select/src/Base/BasePopup.jsx b/components/vc-tree-select/src/Base/BasePopup.jsx index 6de0cede9..571147cd5 100644 --- a/components/vc-tree-select/src/Base/BasePopup.jsx +++ b/components/vc-tree-select/src/Base/BasePopup.jsx @@ -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: { diff --git a/components/vc-tree-select/src/Select.jsx b/components/vc-tree-select/src/Select.jsx index 69678c7d9..3c084985f 100644 --- a/components/vc-tree-select/src/Select.jsx +++ b/components/vc-tree-select/src/Select.jsx @@ -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 { diff --git a/components/vc-tree/src/Tree.jsx b/components/vc-tree/src/Tree.jsx index aa2840b00..6647e37be 100644 --- a/components/vc-tree/src/Tree.jsx +++ b/components/vc-tree/src/Tree.jsx @@ -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 },