mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-09 17:25:38 +00:00
9 lines
247 B
TypeScript
9 lines
247 B
TypeScript
import { useRef } from 'react';
|
|
import fastDeepEuqal from 'fast-deep-equal';
|
|
|
|
export const useStableValue = <T>(value: T): T => {
|
|
const ref = useRef(value);
|
|
if (!fastDeepEuqal(ref.current, value)) ref.current = value;
|
|
return ref.current;
|
|
};
|