From 17172908d312e81f3d22cead4c38bd394b8ee7d2 Mon Sep 17 00:00:00 2001 From: eliran goshen Date: Fri, 15 May 2026 14:13:57 +0200 Subject: [PATCH 1/2] using onyx for fix --- package-lock.json | 8 ++--- package.json | 2 +- patches/react-native-onyx/details.md | 7 ---- .../react-native-onyx+3.0.69.patch | 35 ------------------- 4 files changed, 5 insertions(+), 47 deletions(-) delete mode 100644 patches/react-native-onyx/details.md delete mode 100644 patches/react-native-onyx/react-native-onyx+3.0.69.patch diff --git a/package-lock.json b/package-lock.json index 7d036454b610..63b35afdda18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -115,7 +115,7 @@ "react-native-localize": "^3.5.4", "react-native-nitro-modules": "0.35.0", "react-native-nitro-sqlite": "9.6.0", - "react-native-onyx": "3.0.69", + "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#dd82e39dc9784d59f8237e143771a68707083e2b", "react-native-pager-view": "8.0.0", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0", @@ -34993,9 +34993,9 @@ } }, "node_modules/react-native-onyx": { - "version": "3.0.69", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-3.0.69.tgz", - "integrity": "sha512-J12iRFr4eXr1faolajLG47+P1JjToiju52+tcyyvFZB+9ik3FLiezbvz56udZd4TZi7M3mkRLuAMyzPv7BNE8w==", + "version": "3.0.74", + "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#dd82e39dc9784d59f8237e143771a68707083e2b", + "integrity": "sha512-hlzoEglfEmlMO4/vgbfuBVLlzPznHPfTn6/KbsKc8bdkFMUHvmA4oMHCCmeVZn3aSL/qWe9eHt/F2REGAzVVDA==", "license": "MIT", "dependencies": { "ascii-table": "0.0.9", diff --git a/package.json b/package.json index dcf047214dec..6e6a9029cfc2 100644 --- a/package.json +++ b/package.json @@ -179,7 +179,7 @@ "react-native-localize": "^3.5.4", "react-native-nitro-modules": "0.35.0", "react-native-nitro-sqlite": "9.6.0", - "react-native-onyx": "3.0.69", + "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#dd82e39dc9784d59f8237e143771a68707083e2b", "react-native-pager-view": "8.0.0", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0", diff --git a/patches/react-native-onyx/details.md b/patches/react-native-onyx/details.md deleted file mode 100644 index b544adfc56b9..000000000000 --- a/patches/react-native-onyx/details.md +++ /dev/null @@ -1,7 +0,0 @@ -# `react-native-onyx` patches - -### [react-native-onyx+3.0.69.patch](react-native-onyx+3.0.69.patch) - -- Reason: Onyx v3.0.59 ([PR #756](https://github.com/Expensify/react-native-onyx/pull/756)) added a state reset inside the `subscribe` callback of `useOnyx` to fix stale data when keys change dynamically. However, this reset runs unconditionally — including on initial mount — which causes `useSyncExternalStore` to see a new snapshot reference after subscription, triggering one extra render per `useOnyx` hook. This patch guards the reset with a `hasMountedRef` flag so it only runs on key-change re-subscriptions, not on initial mount. -- E/App issue: https://github.com/Expensify/App/issues/85416 -- Upstream PR/issue: N/A diff --git a/patches/react-native-onyx/react-native-onyx+3.0.69.patch b/patches/react-native-onyx/react-native-onyx+3.0.69.patch deleted file mode 100644 index 7b321b0f51de..000000000000 --- a/patches/react-native-onyx/react-native-onyx+3.0.69.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/node_modules/react-native-onyx/dist/useOnyx.js b/node_modules/react-native-onyx/dist/useOnyx.js -index b361d0d..4df16fa 100644 ---- a/node_modules/react-native-onyx/dist/useOnyx.js -+++ b/node_modules/react-native-onyx/dist/useOnyx.js -@@ -97,6 +97,9 @@ function useOnyx(key, options, dependencies = []) { - // after cleanup), so the hook automatically enters first-connection mode for the new key without any - // explicit reset logic — eliminating the race condition where cleanup could clobber a boolean flag. - const connectedKeyRef = (0, react_1.useRef)(null); -+ // Tracks whether the hook has completed its initial mount subscription. -+ // Unlike connectedKeyRef (which gets nulled by cleanup), this persists across re-subscriptions. -+ const hasMountedRef = (0, react_1.useRef)(false); - // Indicates if the hook is connecting to an Onyx key. - const isConnectingRef = (0, react_1.useRef)(false); - // Stores the `onStoreChange()` function, which can be used to trigger a `getSnapshot()` update when desired. -@@ -220,11 +223,15 @@ function useOnyx(key, options, dependencies = []) { - const subscribe = (0, react_1.useCallback)((onStoreChange) => { - // Reset internal state so the hook properly transitions through loading - // for the new key instead of preserving stale state from the previous one. -- previousValueRef.current = null; -- newValueRef.current = null; -- shouldGetCachedValueRef.current = true; -- sourceValueRef.current = undefined; -- resultRef.current = [undefined, { status: (options === null || options === void 0 ? void 0 : options.initWithStoredValues) === false ? 'loaded' : 'loading' }]; -+ // Only reset when the key has actually changed (not on initial mount). -+ if (hasMountedRef.current) { -+ previousValueRef.current = null; -+ newValueRef.current = null; -+ shouldGetCachedValueRef.current = true; -+ sourceValueRef.current = undefined; -+ resultRef.current = [undefined, { status: (options === null || options === void 0 ? void 0 : options.initWithStoredValues) === false ? 'loaded' : 'loading' }]; -+ } -+ hasMountedRef.current = true; - isConnectingRef.current = true; - onStoreChangeFnRef.current = onStoreChange; - connectionRef.current = OnyxConnectionManager_1.default.connect({ From 09b1c738eb103a0a9e59544937e124cdcff1afe3 Mon Sep 17 00:00:00 2001 From: eliran goshen Date: Mon, 18 May 2026 10:40:51 +0200 Subject: [PATCH 2/2] Bump react-native-onyx SHA to latest PR #784 head Picks up the sync-throw handling fix in https://github.com/Expensify/react-native-onyx/pull/784#discussion_r3249353752. --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 63b35afdda18..c674fe4e64ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -115,7 +115,7 @@ "react-native-localize": "^3.5.4", "react-native-nitro-modules": "0.35.0", "react-native-nitro-sqlite": "9.6.0", - "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#dd82e39dc9784d59f8237e143771a68707083e2b", + "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#b131e24a4ae126fbd74d7cb2f39ef255a9ed64c4", "react-native-pager-view": "8.0.0", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0", @@ -34994,8 +34994,8 @@ }, "node_modules/react-native-onyx": { "version": "3.0.74", - "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#dd82e39dc9784d59f8237e143771a68707083e2b", - "integrity": "sha512-hlzoEglfEmlMO4/vgbfuBVLlzPznHPfTn6/KbsKc8bdkFMUHvmA4oMHCCmeVZn3aSL/qWe9eHt/F2REGAzVVDA==", + "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#b131e24a4ae126fbd74d7cb2f39ef255a9ed64c4", + "integrity": "sha512-pNcVqn39kxgJnRPVL6SKOjjEeRHgTB59K5j2ajNbV2+EoX95LXyWl4CXS+NaVezl8Bh7w51PAJ4jkCqefZH85g==", "license": "MIT", "dependencies": { "ascii-table": "0.0.9", diff --git a/package.json b/package.json index 6e6a9029cfc2..2335f209264a 100644 --- a/package.json +++ b/package.json @@ -179,7 +179,7 @@ "react-native-localize": "^3.5.4", "react-native-nitro-modules": "0.35.0", "react-native-nitro-sqlite": "9.6.0", - "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#dd82e39dc9784d59f8237e143771a68707083e2b", + "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#b131e24a4ae126fbd74d7cb2f39ef255a9ed64c4", "react-native-pager-view": "8.0.0", "react-native-pdf": "7.0.2", "react-native-permissions": "^5.4.0",