source: node_modules/@reduxjs/toolkit/src/query/react/useSerializedStableValue.ts@ a762898

Last change on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 432 bytes
Line 
1import { useEffect, useRef, useMemo } from './reactImports'
2import { copyWithStructuralSharing } from './rtkqImports'
3
4export function useStableQueryArgs<T>(queryArgs: T) {
5 const cache = useRef(queryArgs)
6 const copy = useMemo(
7 () => copyWithStructuralSharing(cache.current, queryArgs),
8 [queryArgs],
9 )
10 useEffect(() => {
11 if (cache.current !== copy) {
12 cache.current = copy
13 }
14 }, [copy])
15
16 return copy
17}
Note: See TracBrowser for help on using the repository browser.