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

14 lines
372 B
Plaintext

import { useEffect, useRef } from './reactImports'
import { shallowEqual } from './reactReduxImports'
export function useShallowStableValue<T>(value: T) {
const cache = useRef(value)
useEffect(() => {
if (!shallowEqual(cache.current, value)) {
cache.current = value
}
}, [value])
return shallowEqual(cache.current, value) ? cache.current : value
}