|
| 1 | +diff --git a/node_modules/react-native-onyx/dist/useOnyx.js b/node_modules/react-native-onyx/dist/useOnyx.js |
| 2 | +index b361d0d..4df16fa 100644 |
| 3 | +--- a/node_modules/react-native-onyx/dist/useOnyx.js |
| 4 | ++++ b/node_modules/react-native-onyx/dist/useOnyx.js |
| 5 | +@@ -97,6 +97,9 @@ function useOnyx(key, options, dependencies = []) { |
| 6 | + // after cleanup), so the hook automatically enters first-connection mode for the new key without any |
| 7 | + // explicit reset logic — eliminating the race condition where cleanup could clobber a boolean flag. |
| 8 | + const connectedKeyRef = (0, react_1.useRef)(null); |
| 9 | ++ // Tracks whether the hook has completed its initial mount subscription. |
| 10 | ++ // Unlike connectedKeyRef (which gets nulled by cleanup), this persists across re-subscriptions. |
| 11 | ++ const hasMountedRef = (0, react_1.useRef)(false); |
| 12 | + // Indicates if the hook is connecting to an Onyx key. |
| 13 | + const isConnectingRef = (0, react_1.useRef)(false); |
| 14 | + // Stores the `onStoreChange()` function, which can be used to trigger a `getSnapshot()` update when desired. |
| 15 | +@@ -220,11 +223,15 @@ function useOnyx(key, options, dependencies = []) { |
| 16 | + const subscribe = (0, react_1.useCallback)((onStoreChange) => { |
| 17 | + // Reset internal state so the hook properly transitions through loading |
| 18 | + // for the new key instead of preserving stale state from the previous one. |
| 19 | +- previousValueRef.current = null; |
| 20 | +- newValueRef.current = null; |
| 21 | +- shouldGetCachedValueRef.current = true; |
| 22 | +- sourceValueRef.current = undefined; |
| 23 | +- resultRef.current = [undefined, { status: (options === null || options === void 0 ? void 0 : options.initWithStoredValues) === false ? 'loaded' : 'loading' }]; |
| 24 | ++ // Only reset when the key has actually changed (not on initial mount). |
| 25 | ++ if (hasMountedRef.current) { |
| 26 | ++ previousValueRef.current = null; |
| 27 | ++ newValueRef.current = null; |
| 28 | ++ shouldGetCachedValueRef.current = true; |
| 29 | ++ sourceValueRef.current = undefined; |
| 30 | ++ resultRef.current = [undefined, { status: (options === null || options === void 0 ? void 0 : options.initWithStoredValues) === false ? 'loaded' : 'loading' }]; |
| 31 | ++ } |
| 32 | ++ hasMountedRef.current = true; |
| 33 | + isConnectingRef.current = true; |
| 34 | + onStoreChangeFnRef.current = onStoreChange; |
| 35 | + connectionRef.current = OnyxConnectionManager_1.default.connect({ |
0 commit comments