Skip to content

feat(frontend): enable React StrictMode at root#39893

Merged
rusackas merged 3 commits into
masterfrom
feat/react-strict-mode
May 11, 2026
Merged

feat(frontend): enable React StrictMode at root#39893
rusackas merged 3 commits into
masterfrom
feat/react-strict-mode

Conversation

@rusackas
Copy link
Copy Markdown
Member

@rusackas rusackas commented May 5, 2026

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

  • Dev-only. StrictMode is a no-op in production React builds; this PR has zero production impact.
  • Test suite unaffected. The custom RTL render wrapper at spec/helpers/testing-library.tsx does not enable StrictMode, so existing tests behave identically.
  • No effect-cleanup audit in this PR. The tracking issue's own guidance is "Expect a follow-up wave of small fixes once it's on. Plan for a cleanup pass; don't merge alongside other work." Any double-mount issues that surface during local dev should be triaged as discrete follow-ups against TODO: Adopt React 18 concurrent features now that the upgrade has landed #39890.

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

  1. npm run dev from superset-frontend/.
  2. Load any page (dashboard, explore, SQL Lab, embedded) — verify the app renders normally.
  3. Open the browser console; existing functionality should work. Expect possible new warnings from React about effects/refs in components that aren't yet idempotent — these are not regressions from this PR but are pre-existing issues StrictMode is now surfacing.
  4. Run npm run build to confirm production builds still succeed (StrictMode is stripped in prod).

ADDITIONAL INFORMATION

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>
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 5, 2026

Code Review Agent Run #541f49

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 893a780..893a780
    • superset-frontend/src/embedded/index.tsx
    • superset-frontend/src/views/index.tsx
    • superset-frontend/src/views/menu.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added the change:frontend Requires changing the frontend label May 5, 2026
Comment thread superset-frontend/src/embedded/index.tsx
@bito-code-review
Copy link
Copy Markdown
Contributor

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

import { useEffect } from 'react';

// Inside EmbededLazyDashboardPage
function EmbededLazyDashboardPage() {
  // ... existing code ...
  useEffect(() => {
    if (uiConfig.emitDataMasks) {
      let previousDataMask = store.getState().dataMask;
      const unsubscribe = store.subscribe(() => {
        const currentDataMask = store.getState().dataMask;
        if (currentDataMask !== previousDataMask) {
          previousDataMask = currentDataMask;
          Switchboard.emit('observeDataMask', ...);
        }
      });
      return unsubscribe;
    }
  }, [uiConfig.emitDataMasks]);
  // Remove the inline subscribe logic
}

@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 893a780
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69fa1f712f117b0008657e4c
😎 Deploy Preview https://deploy-preview-39893--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.38%. Comparing base (9e91ae8) to head (85f8b4c).
⚠️ Report is 41 commits behind head on master.

Files with missing lines Patch % Lines
superset-frontend/src/embedded/index.tsx 0.00% 7 Missing ⚠️
superset-frontend/src/views/menu.tsx 0.00% 2 Missing ⚠️
superset-frontend/src/views/index.tsx 0.00% 1 Missing ⚠️
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           
Flag Coverage Δ
javascript 66.64% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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>
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 6, 2026

Code Review Agent Run #4a46a4

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 893a780..04dcd88
    • superset-frontend/src/embedded/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Redux store.subscribe for data mask emission into a useEffect with 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.

Comment thread superset-frontend/src/embedded/index.tsx Outdated
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>
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 9, 2026

Code Review Agent Run #8e9f24

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 04dcd88..85f8b4c
    • superset-frontend/src/embedded/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Copy link
Copy Markdown
Member

@msyavuz msyavuz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rusackas rusackas merged commit 516bb19 into master May 11, 2026
72 checks passed
@rusackas rusackas deleted the feat/react-strict-mode branch May 11, 2026 16:48
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
Co-authored-by: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants