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

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

Added visualizations

  • Property mode set to 100644
File size: 372 bytes
Line 
1import { useEffect, useRef } from './reactImports'
2import { shallowEqual } from './reactReduxImports'
3
4export function useShallowStableValue<T>(value: T) {
5 const cache = useRef(value)
6 useEffect(() => {
7 if (!shallowEqual(cache.current, value)) {
8 cache.current = value
9 }
10 }, [value])
11
12 return shallowEqual(cache.current, value) ? cache.current : value
13}
Note: See TracBrowser for help on using the repository browser.