Stabilize workspace stream render boundaries
This commit is contained in:
@@ -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), []);
|
||||
}
|
||||
Reference in New Issue
Block a user