Stabilize workspace stream render boundaries

This commit is contained in:
Mohamed Boudra
2026-03-23 10:45:48 +07:00
parent 7f9dafab68
commit 87145f1e6a
4 changed files with 117 additions and 40 deletions
@@ -0,0 +1,10 @@
import { useCallback, useRef } from "react";
export function useStableEvent<TArgs extends unknown[], TResult>(
handler: (...args: TArgs) => TResult,
): (...args: TArgs) => TResult {
const handlerRef = useRef(handler);
handlerRef.current = handler;
return useCallback((...args: TArgs) => handlerRef.current(...args), []);
}