summaryrefslogtreecommitdiffstats
path: root/packages/excalidraw/hooks/useStable.ts
blob: 56608489db175c0e86eb0c638c23f777ebdc228d (plain) (blame)
1
2
3
4
5
6
7
import { useRef } from "react";

export const useStable = <T extends Record<string, any>>(value: T) => {
  const ref = useRef<T>(value);
  Object.assign(ref.current, value);
  return ref.current;
};