fix(useAsyncCallback): update component mount state handling to prevent ref issues in StrictMode - #45285
Conversation
…nt ref issues in StrictMode
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
I also ran into this issue, Network fee was not loading in the Send flow. |
MajorLift
left a comment
There was a problem hiding this comment.
Good call. Also documented this in this ticket for defining a useIsMounted hook: https://github.com/MetaMask/MetaMask-planning/issues/6544
|
Thanks so much for the quick fix 🙏🏻 |
|
Builds ready [7b70295]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 16 warn · 🔴 1 fail)
Bundle size diffs
|



Description
This
useAsyncCallbackin dev StrictMode loses its data on refire (via unmount/remount). Caused issues with token details page openingChangelog
CHANGELOG entry: fix(useAsyncCallback): update component mount state handling to prevent ref issues in StrictMode
Related issues
Fixes: N/A
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Two-line hook lifecycle change; fixes dev StrictMode behavior without altering production mount/unmount semantics.
Overview
useAsyncCallbacknow setsisMounted.current = truewhen its mount effect runs, not only on cleanup tofalse. In React StrictMode (dev), the simulated unmount left the ref false after remount, soexecutecould bail out immediately and async results never updated—e.g. token details after search.useAsyncResultinherits the fix because it builds onuseAsyncCallback.Reviewed by Cursor Bugbot for commit 7b70295. Bugbot is set up for automated code reviews on this repo. Configure here.