Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
18 lines
432 B
Plaintext
18 lines
432 B
Plaintext
import { useEffect, useRef, useMemo } from './reactImports'
|
|
import { copyWithStructuralSharing } from './rtkqImports'
|
|
|
|
export function useStableQueryArgs<T>(queryArgs: T) {
|
|
const cache = useRef(queryArgs)
|
|
const copy = useMemo(
|
|
() => copyWithStructuralSharing(cache.current, queryArgs),
|
|
[queryArgs],
|
|
)
|
|
useEffect(() => {
|
|
if (cache.current !== copy) {
|
|
cache.current = copy
|
|
}
|
|
}, [copy])
|
|
|
|
return copy
|
|
}
|