Skip to content

Commit 3f5a06e

Browse files
authored
fix: kip useless active (#25)
1 parent 757821e commit 3f5a06e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/hooks/useStatus.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,19 @@ export default function useStatus(
7676
return;
7777
}
7878

79+
const currentActive = activeRef.current;
80+
7981
let canEnd: boolean | void;
80-
if (status === STATUS_APPEAR && activeRef.current) {
82+
if (status === STATUS_APPEAR && currentActive) {
8183
canEnd = onAppearEnd?.(element, event);
82-
} else if (status === STATUS_ENTER && activeRef.current) {
84+
} else if (status === STATUS_ENTER && currentActive) {
8385
canEnd = onEnterEnd?.(element, event);
84-
} else if (status === STATUS_LEAVE && activeRef.current) {
86+
} else if (status === STATUS_LEAVE && currentActive) {
8587
canEnd = onLeaveEnd?.(element, event);
8688
}
8789

8890
// Only update status when `canEnd` and not destroyed
89-
if (canEnd !== false) {
91+
if (status !== STATUS_NONE && currentActive && canEnd !== false) {
9092
setStatus(STATUS_NONE, true);
9193
setStyle(null, true);
9294
}

0 commit comments

Comments
 (0)