Fix URLBar expanded state inner buttons

This commit is contained in:
Gregory Schier
2024-01-18 20:40:56 -08:00
parent 56d4212f68
commit 18ea9dda3d
5 changed files with 8 additions and 8 deletions

View File

@@ -0,0 +1,12 @@
import type { Dispatch, SetStateAction } from 'react';
import { useMemo, useState } from 'react';
import { debounce } from '../lib/debounce';
export function useDebouncedState<T>(
defaultValue: T,
delay?: number,
): [T, Dispatch<SetStateAction<T>>, Dispatch<SetStateAction<T>>] {
const [state, setState] = useState<T>(defaultValue);
const debouncedSetState = useMemo(() => debounce(setState, delay), [delay]);
return [state, debouncedSetState, setState];
}