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 = {
33 rules : {
44 'default-case' : 0 ,
55 'import/no-extraneous-dependencies' : 0 ,
6+ 'react-hooks/exhaustive-deps' : 0 ,
67 'react/no-find-dom-node' : 0 ,
78 'react/no-did-update-set-state' : 0 ,
89 'react/no-unused-state' : 1 ,
Original file line number Diff line number Diff line change @@ -21,8 +21,17 @@ export default (
2121 visible : boolean ,
2222 doMeasure : Func ,
2323) : [ PopupStatus , ( callback ?: ( ) => void ) => void ] => {
24- const [ status , setStatus ] = useState < PopupStatus > ( null ) ;
24+ const [ status , setInternalStatus ] = useState < PopupStatus > ( null ) ;
2525 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+ }
2635
2736 function cancelRaf ( ) {
2837 raf . cancel ( rafRef . current ) ;
@@ -63,7 +72,6 @@ export default (
6372 }
6473
6574 if ( status ) {
66- cancelRaf ( ) ;
6775 rafRef . current = raf ( async ( ) => {
6876 const index = StatusQueue . indexOf ( status ) ;
6977 const nextStatus = StatusQueue [ index + 1 ] ;
@@ -76,6 +84,7 @@ export default (
7684
7785 useEffect (
7886 ( ) => ( ) => {
87+ destroyRef . current = true ;
7988 cancelRaf ( ) ;
8089 } ,
8190 [ ] ,
You can’t perform that action at this time.
0 commit comments