fix: avoid state update after notifications modal unmount#40415
fix: avoid state update after notifications modal unmount#40415davidmurdoch wants to merge 3 commits intomainfrom
Conversation
|
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. |
|
Builds ready [3d5a9e7]
⚡ Performance Benchmarks (1478 ± 128 ms)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a React anti-pattern in the notifications activation modal where setIsLoading was being called purely for side effects (analytics tracking) without actually updating state. This could trigger React warnings if the modal unmounted during the close operation. The fix checks isLoading directly before calling hideModal(), eliminating the unnecessary state setter while preserving the analytics behavior.
Changes:
- Refactored
handleHideModalto checkisLoadingdirectly instead of usingsetIsLoadingas a no-op wrapper for analytics tracking - Eliminated potential React unmounted-update warnings during modal close
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Builds ready [b55bd9b]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|



Description
The notifications activation modal was performing a no-op
setIsLoadingupdate during close only to run analytics side effects. If the modal unmounted during close, this could trigger React unmounted-update warnings. The fix removes the unnecessary state setter and keeps the tracking behavior by checkingisLoadingdirectly beforehideModal().I think this may fix a race condition that happens in our integration tests from time to time.
Changelog
CHANGELOG entry: null
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Low risk: small change to notifications activation modal close behavior to remove a no-op state update and keep analytics tracking, with added tests to guard ordering and metrics emission.
Overview
Prevents React unmounted-update warnings when dismissing the notifications activation modal by removing the no-op
setIsLoadingcall used only for side effects and instead conditionally tracking the "dismissed" metric directly beforehideModal().Adds/updates tests to assert dismissal metrics are sent and that
trackEventis invoked before the modal is hidden, reducing flakiness in the notifications activation integration flow.Written by Cursor Bugbot for commit b55bd9b. This will update automatically on new commits. Configure here.