refactor: routes.component.js and creation of ToastMaster
Description
This PR is part of the larger effort to add React.lazy to routes.
I would be very surprised if I did not break functionality somewhere, as this was a large and tough refactor. It needs some good QA, and Harika has been doing some testing that has passed.
Summary of what I did:
- Pulled all Toast-related logic out of routes.component.js and into the new ToastMaster
- Pulled everything else I could pull out into routes-helpers.js
- Moved things out of the general selectors.js and actions.ts into toast-master-selectors.ts
- Simplification of some Pointless Thunks™
For later PRs:
- Convert routes.component.js to TypeScript
- Convert routes.component.js to Hooks
- Convert routes.component.js to react-router v6
- Eliminate routes.container.js
Related issues
Progresses: MetaMask/MetaMask-planning#2898
Manual testing steps
Test all the Routes and all the Toasts
Screenshots/Recordings
Before
After
Pre-merge author checklist
- [x] I've followed MetaMask Contributor Docs and MetaMask Extension Coding Standards.
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using JSDoc format if applicable
- [x] I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
Pre-merge reviewer checklist
- [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
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 [0eb601f]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1892 ± 86 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 383 | 2162 | 1787 | 347 | 166 |
| domContentLoaded | 1528 | 2425 | 1868 | 176 | 84 | ||
| load | 1536 | 2436 | 1892 | 178 | 86 | ||
| domInteractive | 14 | 107 | 40 | 21 | 10 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 3.7 KiB (0.05%)
- common: -2.32 KiB (-0.03%)
Builds ready [789eb79]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1815 ± 96 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 426 | 2595 | 1754 | 377 | 181 |
| domContentLoaded | 1589 | 2362 | 1773 | 184 | 88 | ||
| load | 1608 | 2450 | 1815 | 199 | 96 | ||
| domInteractive | 26 | 74 | 43 | 16 | 8 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 3.66 KiB (0.05%)
- common: -2.32 KiB (-0.03%)
Builds ready [553bbe2]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1858 ± 70 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 300 | 2146 | 1774 | 359 | 172 |
| domContentLoaded | 1601 | 1991 | 1802 | 96 | 46 | ||
| load | 1625 | 2327 | 1858 | 147 | 70 | ||
| domInteractive | 18 | 84 | 52 | 20 | 10 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 3.66 KiB (0.05%)
- common: -2.31 KiB (-0.03%)
Builds ready [7a54b36]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (2010 ± 314 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 480 | 4607 | 1876 | 703 | 338 |
| domContentLoaded | 1564 | 4436 | 1978 | 650 | 312 | ||
| load | 1614 | 4497 | 2010 | 653 | 314 | ||
| domInteractive | 26 | 143 | 50 | 29 | 14 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 6.1 KiB (0.08%)
- common: -2.68 KiB (-0.04%)
Builds ready [2aad6bf]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1779 ± 41 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 1655 | 1976 | 1787 | 91 | 44 |
| domContentLoaded | 1644 | 1953 | 1756 | 78 | 38 | ||
| load | 1656 | 1961 | 1779 | 85 | 41 | ||
| domInteractive | 24 | 78 | 45 | 18 | 9 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 5.36 KiB (0.07%)
- common: -2.68 KiB (-0.04%)
Builds ready [21a771a]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (2057 ± 180 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 375 | 3158 | 1957 | 483 | 232 |
| domContentLoaded | 1684 | 2596 | 1966 | 226 | 109 | ||
| load | 1693 | 3465 | 2057 | 376 | 180 | ||
| domInteractive | 18 | 87 | 51 | 22 | 11 | ||
| backgroundConnect | 9 | 863 | 89 | 183 | 88 | ||
| firstReactRender | 47 | 288 | 128 | 63 | 30 | ||
| getState | 4 | 89 | 30 | 26 | 13 | ||
| initialActions | 0 | 1 | 0 | 0 | 0 | ||
| loadScripts | 1223 | 1853 | 1471 | 182 | 87 | ||
| setupStore | 11 | 95 | 34 | 29 | 14 | ||
| uiStartup | 1903 | 3687 | 2378 | 403 | 194 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 5.36 KiB (0.07%)
- common: -2.67 KiB (-0.04%)
Builds ready [2dd77de]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1729 ± 96 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 1509 | 2286 | 1725 | 196 | 94 |
| domContentLoaded | 1483 | 2008 | 1670 | 138 | 66 | ||
| load | 1495 | 2282 | 1729 | 200 | 96 | ||
| domInteractive | 17 | 342 | 57 | 67 | 32 | ||
| backgroundConnect | 9 | 252 | 59 | 71 | 34 | ||
| firstReactRender | 43 | 207 | 109 | 53 | 25 | ||
| getState | 4 | 106 | 19 | 29 | 14 | ||
| initialActions | 0 | 1 | 0 | 0 | 0 | ||
| loadScripts | 1078 | 1474 | 1252 | 103 | 49 | ||
| setupStore | 11 | 101 | 49 | 34 | 17 | ||
| uiStartup | 1661 | 3187 | 2044 | 394 | 189 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 5.49 KiB (0.07%)
- common: -2.67 KiB (-0.04%)
Builds ready [640f88a]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (2349 ± 335 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 285 | 3887 | 2036 | 948 | 455 |
| domContentLoaded | 1639 | 3876 | 2302 | 700 | 336 | ||
| load | 1691 | 3896 | 2349 | 698 | 335 | ||
| domInteractive | 19 | 165 | 72 | 46 | 22 | ||
| backgroundConnect | 7 | 165 | 49 | 36 | 17 | ||
| firstReactRender | 49 | 304 | 115 | 67 | 32 | ||
| getState | 6 | 79 | 27 | 21 | 10 | ||
| initialActions | 0 | 1 | 0 | 0 | 0 | ||
| loadScripts | 1202 | 3012 | 1744 | 582 | 279 | ||
| setupStore | 11 | 76 | 34 | 22 | 11 | ||
| uiStartup | 1840 | 4274 | 2646 | 802 | 385 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 5.54 KiB (0.07%)
- common: -2.67 KiB (-0.04%)
Builds ready [e5bbb59]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1926 ± 171 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 1550 | 3037 | 1919 | 357 | 171 |
| domContentLoaded | 1538 | 3022 | 1890 | 349 | 168 | ||
| load | 1554 | 3035 | 1926 | 356 | 171 | ||
| domInteractive | 18 | 132 | 45 | 28 | 13 | ||
| backgroundConnect | 11 | 138 | 37 | 32 | 15 | ||
| firstReactRender | 46 | 198 | 87 | 35 | 17 | ||
| getState | 4 | 58 | 12 | 14 | 7 | ||
| initialActions | 0 | 1 | 0 | 0 | 0 | ||
| loadScripts | 1118 | 2615 | 1441 | 337 | 162 | ||
| setupStore | 11 | 72 | 32 | 23 | 11 | ||
| uiStartup | 1753 | 3241 | 2145 | 394 | 189 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 5.48 KiB (0.07%)
- common: -2.67 KiB (-0.04%)
Builds ready [65bbd8c]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1802 ± 84 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 1556 | 2177 | 1805 | 176 | 85 |
| domContentLoaded | 1507 | 2133 | 1776 | 172 | 83 | ||
| load | 1560 | 2179 | 1802 | 175 | 84 | ||
| domInteractive | 16 | 212 | 56 | 50 | 24 | ||
| backgroundConnect | 9 | 77 | 24 | 20 | 9 | ||
| firstReactRender | 43 | 300 | 112 | 62 | 30 | ||
| getState | 4 | 69 | 14 | 19 | 9 | ||
| initialActions | 0 | 1 | 0 | 0 | 0 | ||
| loadScripts | 1023 | 1592 | 1311 | 140 | 67 | ||
| setupStore | 11 | 95 | 27 | 26 | 13 | ||
| uiStartup | 1704 | 2570 | 2037 | 247 | 119 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 5.48 KiB (0.07%)
- common: -2.67 KiB (-0.03%)
Builds ready [bfd7b86]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1828 ± 76 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 1518 | 2202 | 1830 | 148 | 71 |
| domContentLoaded | 1473 | 2023 | 1776 | 116 | 56 | ||
| load | 1481 | 2215 | 1828 | 159 | 76 | ||
| domInteractive | 16 | 102 | 51 | 23 | 11 | ||
| backgroundConnect | 9 | 258 | 55 | 66 | 31 | ||
| firstReactRender | 51 | 285 | 121 | 62 | 30 | ||
| getState | 4 | 118 | 28 | 30 | 14 | ||
| initialActions | 0 | 0 | 0 | 0 | 0 | ||
| loadScripts | 1071 | 1527 | 1325 | 94 | 45 | ||
| setupStore | 10 | 122 | 39 | 35 | 17 | ||
| uiStartup | 1665 | 3063 | 2147 | 329 | 158 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 5.48 KiB (0.07%)
- common: -2.67 KiB (-0.03%)
Builds ready [a66fe4f]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1818 ± 98 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 318 | 2466 | 1738 | 377 | 181 |
| domContentLoaded | 1568 | 2207 | 1770 | 140 | 67 | ||
| load | 1582 | 2519 | 1818 | 204 | 98 | ||
| domInteractive | 15 | 95 | 51 | 22 | 11 | ||
| backgroundConnect | 8 | 259 | 46 | 63 | 30 | ||
| firstReactRender | 47 | 208 | 91 | 47 | 23 | ||
| getState | 5 | 171 | 30 | 47 | 22 | ||
| initialActions | 0 | 0 | 0 | 0 | 0 | ||
| loadScripts | 1116 | 1660 | 1305 | 121 | 58 | ||
| setupStore | 11 | 136 | 43 | 34 | 16 | ||
| uiStartup | 1771 | 3307 | 2079 | 361 | 173 |
Bundle size diffs [🚀 Bundle size reduced!]
- background: 0 Bytes (0.00%)
- ui: 5.48 KiB (0.07%)
- common: -2.67 KiB (-0.03%)
Builds ready [e82745e]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1794 ± 74 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 354 | 2386 | 1659 | 461 | 221 |
| domContentLoaded | 1651 | 2143 | 1761 | 106 | 51 | ||
| load | 1660 | 2385 | 1794 | 155 | 74 | ||
| domInteractive | 17 | 97 | 41 | 18 | 8 | ||
| backgroundConnect | 9 | 205 | 34 | 50 | 24 | ||
| firstReactRender | 46 | 211 | 98 | 42 | 20 | ||
| getState | 4 | 94 | 21 | 27 | 13 | ||
| initialActions | 0 | 0 | 0 | 0 | 0 | ||
| loadScripts | 1188 | 1546 | 1289 | 78 | 37 | ||
| setupStore | 10 | 100 | 35 | 28 | 14 | ||
| uiStartup | 1807 | 3041 | 2056 | 302 | 145 |
