mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-20 16:43:53 +01:00
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
13 lines
471 B
TypeScript
13 lines
471 B
TypeScript
import { debounce } from "@yaakapp-internal/lib";
|
|
import type { Dispatch, SetStateAction } from "react";
|
|
import { useMemo, useState } from "react";
|
|
|
|
export function useDebouncedState<T>(
|
|
defaultValue: T,
|
|
delay = 500,
|
|
): [T, Dispatch<SetStateAction<T>>, Dispatch<SetStateAction<T>>] {
|
|
const [state, setState] = useState<T>(defaultValue);
|
|
const debouncedSetState = useMemo(() => debounce(setState, delay), [delay]);
|
|
return [state, debouncedSetState, setState];
|
|
}
|