mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 14:23:44 +02:00
Update permissions checking code
This commit is contained in:
12
resources/scripts/plugins/useDeepMemo.ts
Normal file
12
resources/scripts/plugins/useDeepMemo.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { useRef } from 'react';
|
||||
import isEqual from 'lodash-es/isEqual';
|
||||
|
||||
export const useDeepMemo = <T, K> (fn: () => T, key: K): T => {
|
||||
const ref = useRef<{ key: K, value: T }>();
|
||||
|
||||
if (!ref.current || !isEqual(key, ref.current.key)) {
|
||||
ref.current = { key, value: fn() };
|
||||
}
|
||||
|
||||
return ref.current.value;
|
||||
};
|
||||
Reference in New Issue
Block a user