File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
packages/smooth/src/router Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ export function HiddenRouter({ children }) {
42
42
const { history } = useRouter ( )
43
43
const hiddenHistory = useHiddenHistory ( )
44
44
const promises = useRef ( [ ] )
45
+ const timeoutRef = useRef ( )
45
46
46
47
const flush = useCallback ( ( ) => {
47
48
if ( promises . current . length || ! hiddenHistory . state ) return
@@ -60,7 +61,8 @@ export function HiddenRouter({ children }) {
60
61
}
61
62
// 65ms is 4 frames, pretty invisible when we change page
62
63
// it ensures that React have time to start a new request for an example
63
- setTimeout ( ( ) => flush ( ) , 65 )
64
+ clearTimeout ( timeoutRef . current )
65
+ timeoutRef . current = setTimeout ( ( ) => flush ( ) , 65 )
64
66
} )
65
67
promises . current . push ( promise )
66
68
} ,
You can’t perform that action at this time.
0 commit comments