1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 17:12:30 +01:00
Pterodactyl-Panel/resources/scripts/plugins/useDeepMemoize.ts

13 lines
346 B
TypeScript

import { DependencyList, MutableRefObject, useRef } from 'react';
import isEqual from 'react-fast-compare';
export const useDeepMemoize = <T = DependencyList>(value: T): T => {
const ref: MutableRefObject<T | undefined> = useRef();
if (!isEqual(value, ref.current)) {
ref.current = value;
}
return ref.current as T;
};