Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions lib/useOnyx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
// Stores the newest cached value in order to compare with the previous one and optimize `getSnapshot()` execution.
const newValueRef = useRef<TReturnValue | undefined | null>(null);

const lastConnectedKeyRef = useRef<TKey>(key);

// Stores the previously result returned by the hook, containing the data from cache and the fetch status.
// We initialize it to `undefined` and `loading` fetch status to simulate the initial result when the hook is loading from the cache.
// However, if `initWithStoredValues` is `false` we set the fetch status to `loaded` since we want to signal that data is ready.
Expand Down Expand Up @@ -164,16 +162,6 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(

useEffect(() => () => onyxSnapshotCache.deregisterConsumer(key, cacheKey), [key, cacheKey]);

useEffect(() => {
if (lastConnectedKeyRef.current === key) {
return;
}
lastConnectedKeyRef.current = key;
shouldGetCachedValueRef.current = true;
previousValueRef.current = null;
resultRef.current = [undefined, {status: options?.initWithStoredValues === false ? 'loaded' : 'loading'}];
}, [key, options?.initWithStoredValues]);

useEffect(() => {
// These conditions will ensure we can only handle dynamic collection member keys from the same collection.
if (options?.allowDynamicKey || previousKey === key) {
Expand Down