mirror of
https://github.com/supabase/supabase.git
synced 2026-05-07 01:10:15 -04:00
f2122b64f2
* Use paginated projects endpoint for docs * Deprecate old projects query * Fix * Fix * fix(docs branch selector) * refactor(docs project selector): simplify dom --------- Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
20 lines
541 B
TypeScript
20 lines
541 B
TypeScript
import { useEffect, useState } from 'react'
|
|
|
|
// [Joshen] Copying from uidotdev/usehooks instead of installing the whole package
|
|
// https://github.com/uidotdev/usehooks/blob/945436df0037bc21133379a5e13f1bd73f1ffc36/index.js#L239
|
|
export function useDebounce(value, delay) {
|
|
const [debouncedValue, setDebouncedValue] = useState(value)
|
|
|
|
useEffect(() => {
|
|
const handler = setTimeout(() => {
|
|
setDebouncedValue(value)
|
|
}, delay)
|
|
|
|
return () => {
|
|
clearTimeout(handler)
|
|
}
|
|
}, [value, delay])
|
|
|
|
return debouncedValue
|
|
}
|