Files
SnowLuma/.pnpm-store/v11/files/a6/a3538d20f92852ccfdb5655b874aec8c7b9c0b1bb437e25932b3489bf4a3ecb4a3c6e10ea10b335378994db2380473bf5736a36e641eb41f2c06f8c246bd17
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

21 lines
587 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 };
//# sourceMappingURL=use-constant.mjs.map