MCPcopy
hub / github.com/openai/chatkit-js / useStableOptions

Function useStableOptions

packages/chatkit-react/src/useStableOptions.ts:113–129  ·  view source on GitHub ↗
(options: T)

Source from the content-addressed store, hash-verified

111}
112
113export 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}

Callers 1

useChatKitFunction · 0.90

Calls 2

deepEqualIgnoringFnsFunction · 0.85

Tested by

no test coverage detected