Skip to content

Commit bf06ba0

Browse files
committed
refactor: replace hooks with rc-util useState
1 parent ad116a9 commit bf06ba0

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"classnames": "^2.2.6",
6565
"rc-align": "^4.0.0",
6666
"rc-motion": "^2.0.0",
67-
"rc-util": "^5.5.0"
67+
"rc-util": "^5.19.2"
6868
},
6969
"peerDependencies": {
7070
"react": ">=16.9.0",

src/Popup/useVisibleStatus.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { useState, useEffect, useRef } from 'react';
1+
import { useEffect, useRef } from 'react';
22
import raf from 'rc-util/lib/raf';
3+
import useState from 'rc-util/lib/hooks/useState';
34

45
/**
56
* Popup should follow the steps for each component work correctly:
@@ -23,14 +24,11 @@ export default (
2324
): [PopupStatus, (callback?: () => void) => void] => {
2425
const [status, setInternalStatus] = useState<PopupStatus>(null);
2526
const rafRef = useRef<number>();
26-
const destroyRef = useRef(false);
2727

2828
function setStatus(
2929
nextStatus: PopupStatus | ((prevStatus: PopupStatus) => PopupStatus),
3030
) {
31-
if (!destroyRef.current) {
32-
setInternalStatus(nextStatus);
33-
}
31+
setInternalStatus(nextStatus, true);
3432
}
3533

3634
function cancelRaf() {
@@ -84,7 +82,6 @@ export default (
8482

8583
useEffect(
8684
() => () => {
87-
destroyRef.current = true;
8885
cancelRaf();
8986
},
9087
[],

0 commit comments

Comments
 (0)