Skip to content

Commit 7b00e2c

Browse files
committed
双击会有重复值 #74
1 parent 9b02981 commit 7b00e2c

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

src/pages/HostKeyHash/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ class HostKeyHash extends Component {
3535
let redisKey = this.props.redisKey;
3636
this.refreshValue(redisKey);
3737
}
38+
3839
/**
39-
* 在组件接收到一个新的 prop (更新后)时被调用。这个方法在初始化render时不会被调用。
40+
*组件更新
4041
*
41-
* @param {*} nextProps
42-
* @memberof HostKeyHash
42+
* @param {*} prevProps
43+
* @memberof HostKeyString
4344
*/
44-
UNSAFE_componentWillReceiveProps(nextProps) {
45-
this.props = nextProps;
46-
let redisKey = this.props.redisKey;
47-
this.refreshValue(redisKey);
45+
componentDidUpdate(prevProps) {
46+
if (this.props.redisKey !== prevProps.redisKey) {
47+
this.props = prevProps;
48+
let redisKey = this.props.redisKey;
49+
this.refreshValue(redisKey);
50+
}
4851
}
52+
4953
/**
5054
* table columns
5155
*

src/pages/HostKeySet/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ class HostKeySet extends Component {
3636
this.refreshValue(redisKey);
3737
}
3838
/**
39-
* 在组件接收到一个新的 prop (更新后)时被调用。这个方法在初始化render时不会被调用。
39+
*组件更新
4040
*
41-
* @param {*} nextProps
41+
* @param {*} prevProps
4242
* @memberof HostKeyString
4343
*/
44-
UNSAFE_componentWillReceiveProps(nextProps) {
45-
this.props = nextProps;
46-
let redisKey = this.props.redisKey;
47-
this.refreshValue(redisKey);
44+
componentDidUpdate(prevProps) {
45+
if (this.props.redisKey !== prevProps.redisKey) {
46+
this.props = prevProps;
47+
let redisKey = this.props.redisKey;
48+
this.refreshValue(redisKey);
49+
}
4850
}
4951
/**
5052
* table columns

src/pages/HostKeySortSet/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ class HostKeySortSet extends Component {
3737
this.refreshValue(redisKey);
3838
}
3939
/**
40-
* 在组件接收到一个新的 prop (更新后)时被调用。这个方法在初始化render时不会被调用。
40+
*组件更新
4141
*
42-
* @param {*} nextProps
42+
* @param {*} prevProps
4343
* @memberof HostKeyString
4444
*/
45-
UNSAFE_componentWillReceiveProps(nextProps) {
46-
this.props = nextProps;
47-
let redisKey = this.props.redisKey;
48-
this.refreshValue(redisKey);
45+
componentDidUpdate(prevProps) {
46+
if (this.props.redisKey !== prevProps.redisKey) {
47+
this.props = prevProps;
48+
let redisKey = this.props.redisKey;
49+
this.refreshValue(redisKey);
50+
}
4951
}
5052
/**
5153
* table columns

0 commit comments

Comments
 (0)