Latest repo

This commit is contained in:
Marc
2025-06-02 16:42:16 +00:00
parent 53ddf1a329
commit cde5fae175
27907 changed files with 3875388 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
'use client';
import { useRef } from 'react';
import { isDefined } from '../utils.js';
export default function useCachedValue<T>(getter: () => T): () => T {
const ref = useRef<T | undefined>(undefined);
const currentValue = ref.current;
if (isDefined(currentValue)) {
return () => currentValue;
}
return () => {
const value = getter();
ref.current = value;
return value;
};
}