feat(frontend): enable React StrictMode at root#39893
Conversation
Wrap the three React 18 root mounts (views/index, views/menu, embedded) in <StrictMode>. Refs #39890. StrictMode is dev-only — production builds are unchanged. The RTL test wrapper does not enable StrictMode, so the existing test suite is unaffected. Any double-invocation/cleanup issues that surface during local dev work should be tracked as follow-up items. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code Review Agent Run #541f49Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Yes, the suggestion is valid — StrictMode's double-invocation in development causes the store.subscribe in EmbededLazyDashboardPage's render to create duplicate subscriptions without cleanup, leading to memory leaks and repeated observeDataMask emissions. To resolve, move the subscription logic into useEffect with cleanup: import useEffect, then wrap the subscribe call in useEffect(() => { const unsubscribe = store.subscribe(...); return unsubscribe; }, [uiConfig.emitDataMasks]). There are no other comments on this PR. superset-frontend/src/embedded/index.tsx |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #39893 +/- ##
=======================================
Coverage 64.38% 64.38%
=======================================
Files 2569 2569
Lines 134785 134786 +1
Branches 31295 31295
=======================================
+ Hits 86777 86781 +4
+ Misses 46510 46507 -3
Partials 1498 1498
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Per codeant review on #39893: subscribing to the Redux store from inside the render body of EmbededLazyDashboardPage registered a new listener on every render with no cleanup, leaking subscriptions and double-emitting observeDataMask events on each store update. StrictMode's dev-mode double-mount made the leak immediately visible. Move the subscription into a useEffect keyed on emitDataMasks, returning the Redux unsubscribe so React tears the listener down on unmount. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code Review Agent Run #4a46a4Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
There was a problem hiding this comment.
Pull request overview
Enables React StrictMode at Superset’s three React 18 root entrypoints as a foundation for future concurrent-rendering adoption, and adjusts the embedded app to avoid render-time side effects that StrictMode would surface in development.
Changes:
- Wraps the main app root mount (
views/index.tsx) in<StrictMode>. - Wraps the backend-rendered menu root mount (
views/menu.tsx) in<StrictMode>. - Wraps the embedded root mount in
<StrictMode>and moves the Reduxstore.subscribefor data mask emission into auseEffectwith proper cleanup.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| superset-frontend/src/views/menu.tsx | Wraps the menu-only React mount tree in StrictMode. |
| superset-frontend/src/views/index.tsx | Wraps the main application root render in StrictMode. |
| superset-frontend/src/embedded/index.tsx | Wraps embedded root render in StrictMode and ensures store subscriptions are established/cleaned up via useEffect. |
Rename to EmbeddedLazyDashboardPage. Pre-existing typo flagged by Copilot review on #39893; updated both the definition and the single usage site in the same file. No other references in the codebase. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code Review Agent Run #8e9f24Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Co-authored-by: Claude Code <noreply@anthropic.com>
SUMMARY
First foundational step for #39890 (React 18 concurrent-feature adoption).
Wraps the three React 18 root mounts in
<StrictMode>:superset-frontend/src/views/index.tsx(main app)superset-frontend/src/views/menu.tsx(backend-rendered views' menu)superset-frontend/src/embedded/index.tsx(embedded SDK)Why
Per the React 18 docs, StrictMode's dev-mode double-invocation surfaces effect-cleanup and non-idempotent-render bugs that concurrent rendering will eventually expose at runtime. Turning it on now lets us catch those deliberately during local dev rather than have them appear later as "weird remount" or stale-state regressions.
Scope notes
spec/helpers/testing-library.tsxdoes not enable StrictMode, so existing tests behave identically.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — no UI change. Dev-mode console may now show second-invocation warnings for components with cleanup bugs; those are pre-existing latent issues to be fixed in follow-ups.
TESTING INSTRUCTIONS
npm run devfromsuperset-frontend/.npm run buildto confirm production builds still succeed (StrictMode is stripped in prod).ADDITIONAL INFORMATION