Dedupe navigation events (push, navigate, pop, etc) (#3179)
This commit is contained in:
parent
b8afb935f4
commit
ee57d74765
7 changed files with 118 additions and 25 deletions
17
src/lib/hooks/useDedupe.ts
Normal file
17
src/lib/hooks/useDedupe.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import React from 'react'
|
||||
|
||||
export const useDedupe = () => {
|
||||
const canDo = React.useRef(true)
|
||||
|
||||
return React.useRef((cb: () => unknown) => {
|
||||
if (canDo.current) {
|
||||
canDo.current = false
|
||||
setTimeout(() => {
|
||||
canDo.current = true
|
||||
}, 250)
|
||||
cb()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}).current
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue