File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module.exports = {
3
3
rules : {
4
4
'default-case' : 0 ,
5
5
'import/no-extraneous-dependencies' : 0 ,
6
+ 'react-hooks/exhaustive-deps' : 0 ,
6
7
'react/no-find-dom-node' : 0 ,
7
8
'react/no-did-update-set-state' : 0 ,
8
9
'react/no-unused-state' : 1 ,
Original file line number Diff line number Diff line change @@ -21,8 +21,17 @@ export default (
21
21
visible : boolean ,
22
22
doMeasure : Func ,
23
23
) : [ PopupStatus , ( callback ?: ( ) => void ) => void ] => {
24
- const [ status , setStatus ] = useState < PopupStatus > ( null ) ;
24
+ const [ status , setInternalStatus ] = useState < PopupStatus > ( null ) ;
25
25
const rafRef = useRef < number > ( ) ;
26
+ const destroyRef = useRef ( false ) ;
27
+
28
+ function setStatus (
29
+ nextStatus : PopupStatus | ( ( prevStatus : PopupStatus ) => PopupStatus ) ,
30
+ ) {
31
+ if ( ! destroyRef . current ) {
32
+ setInternalStatus ( nextStatus ) ;
33
+ }
34
+ }
26
35
27
36
function cancelRaf ( ) {
28
37
raf . cancel ( rafRef . current ) ;
@@ -63,7 +72,6 @@ export default (
63
72
}
64
73
65
74
if ( status ) {
66
- cancelRaf ( ) ;
67
75
rafRef . current = raf ( async ( ) => {
68
76
const index = StatusQueue . indexOf ( status ) ;
69
77
const nextStatus = StatusQueue [ index + 1 ] ;
@@ -76,6 +84,7 @@ export default (
76
84
77
85
useEffect (
78
86
( ) => ( ) => {
87
+ destroyRef . current = true ;
79
88
cancelRaf ( ) ;
80
89
} ,
81
90
[ ] ,
You can’t perform that action at this time.
0 commit comments