File tree Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -10,30 +10,20 @@ function HydrateOnIdle({ children, ...rest }: Props) {
1010 React . useEffect ( ( ) => {
1111 if ( hydrated ) return ;
1212
13- const cleanupFns : VoidFunction [ ] = [ ] ;
14-
15- function cleanup ( ) {
16- for ( let i = 0 ; i < cleanupFns . length ; i ++ ) {
17- cleanupFns [ i ] ( ) ;
18- }
19- }
20-
2113 // @ts -ignore
2214 if ( requestIdleCallback ) {
2315 // @ts -ignore
2416 const idleCallbackId = requestIdleCallback ( hydrate , { timeout : 500 } ) ;
25- cleanupFns . push ( ( ) => {
17+ return ( ) => {
2618 // @ts -ignore
2719 cancelIdleCallback ( idleCallbackId ) ;
28- } ) ;
20+ } ;
2921 } else {
3022 const id = setTimeout ( hydrate , 2000 ) ;
31- cleanupFns . push ( ( ) => {
23+ return ( ) => {
3224 clearTimeout ( id ) ;
33- } ) ;
25+ } ;
3426 }
35-
36- return cleanup ;
3727 } , [ hydrated , hydrate ] ) ;
3828
3929 if ( hydrated ) {
You can’t perform that action at this time.
0 commit comments