Skip to content

Commit 2e35b7b

Browse files
authored
Revert "fix: result isn't changed when the member collection change"
1 parent 338b839 commit 2e35b7b

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

lib/useOnyx.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
122122
// Stores the newest cached value in order to compare with the previous one and optimize `getSnapshot()` execution.
123123
const newValueRef = useRef<TReturnValue | undefined | null>(null);
124124

125-
const lastConnectedKeyRef = useRef<TKey>(key);
126-
127125
// Stores the previously result returned by the hook, containing the data from cache and the fetch status.
128126
// We initialize it to `undefined` and `loading` fetch status to simulate the initial result when the hook is loading from the cache.
129127
// However, if `initWithStoredValues` is `false` we set the fetch status to `loaded` since we want to signal that data is ready.
@@ -164,16 +162,6 @@ function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(
164162

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

167-
useEffect(() => {
168-
if (lastConnectedKeyRef.current === key) {
169-
return;
170-
}
171-
lastConnectedKeyRef.current = key;
172-
shouldGetCachedValueRef.current = true;
173-
previousValueRef.current = null;
174-
resultRef.current = [undefined, {status: options?.initWithStoredValues === false ? 'loaded' : 'loading'}];
175-
}, [key, options?.initWithStoredValues]);
176-
177165
useEffect(() => {
178166
// These conditions will ensure we can only handle dynamic collection member keys from the same collection.
179167
if (options?.allowDynamicKey || previousKey === key) {

0 commit comments

Comments
 (0)