(options: T)
| 111 | } |
| 112 | |
| 113 | export function useStableOptions<T extends Record<string, any>>(options: T): T { |
| 114 | const latestOptions = React.useRef(options); |
| 115 | latestOptions.current = options; |
| 116 | const cache = React.useRef<{ snapshot: T; shaped: T } | null>(null); |
| 117 | |
| 118 | if ( |
| 119 | !cache.current || |
| 120 | !deepEqualIgnoringFns(cache.current.snapshot, options) |
| 121 | ) { |
| 122 | cache.current = { |
| 123 | snapshot: options, |
| 124 | shaped: withLatestFunctionWrappers(latestOptions), |
| 125 | }; |
| 126 | } |
| 127 | |
| 128 | return cache.current.shaped; |
| 129 | } |
no test coverage detected