Dedupe navigation events (push, navigate, pop, etc) (#3179)

This commit is contained in:
Hailey 2024-03-12 09:46:25 -07:00 committed by GitHub
parent b8afb935f4
commit ee57d74765
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 118 additions and 25 deletions

View 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
}