Files
NapCatQQ/.pnpm-store/v3/files/1c/26580875c92a5e19e75051874f6a6bb395f80841b27bae584f03e8c836deb6dbbae210aa75f890e10f346dd06c416df0331fce4e2ef71a665dfc06590f1efe
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

20 lines
545 B
Plaintext

"use client";
import { useRef } from 'react';
/**
* Creates a constant value over the lifecycle of a component.
*
* Even if `useMemo` is provided an empty array as its final argument, it doesn't offer
* a guarantee that it won't re-run for performance reasons later on. By using `useConstant`
* you can ensure that initialisers don't execute twice or more.
*/
function useConstant(init) {
const ref = useRef(null);
if (ref.current === null) {
ref.current = init();
}
return ref.current;
}
export { useConstant };