mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 06:13:45 +02:00
Start cleaning up the mess of useServer; make startup page update in real time
This commit is contained in:
12
resources/scripts/plugins/useDeepMemoize.ts
Normal file
12
resources/scripts/plugins/useDeepMemoize.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user