Skip to content

fix: improve doc app dev rendering#6853

Merged
PavelVanecek merged 1 commit intorecharts:mainfrom
cloud-walker:fix-dev-mode
Jan 5, 2026
Merged

fix: improve doc app dev rendering#6853
PavelVanecek merged 1 commit intorecharts:mainfrom
cloud-walker:fix-dev-mode

Conversation

@cloud-walker
Copy link
Contributor

@cloud-walker cloud-walker commented Jan 4, 2026

Description

Enable full client side rendering in non production environments.

Related Issue

#6825

Motivation and Context

Working on the dark mode feature I noticed a bunch of weird react warnings, at the time I thought the app was a simple client side rendered SPA, but then I noticed the hydrateRoot and the prerender.tsx file.

But we are still developing in client side only mode, so.

How Has This Been Tested?

Manually

Screenshots (if appropriate):

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a storybook story or VR test, or extended an existing story or VR test to show my changes

Summary by CodeRabbit

  • Chores
    • Optimized application initialization behavior for production and development environments to improve performance and reliability during app startup.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 4, 2026

Walkthrough

The React app initialization in app.tsx is modified to use conditional rendering based on environment. Production uses server-side hydration with hydrateRoot, while development uses createRoot for standard mounting. A reactTree JSX wrapper containing Root and ColorModeProvider is introduced to support both approaches.

Changes

Cohort / File(s) Summary
React initialization refactor
www/src/app.tsx
Added createRoot import from react-dom/client; introduced reactTree JSX wrapper combining Root and ColorModeProvider; replaced single hydrateRoot call with conditional logic: hydration in production (import.meta.env.PROD) vs createRoot rendering in development; included explanatory comment about SSG behavior differences.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description covers most required sections: it explains the change (client-side rendering in dev), links issue #6825, provides context about React warnings, includes testing notes and a screenshot, and properly marks the type of change as a bug fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The PR title 'fix: improve doc app dev rendering' directly relates to the main change: enabling full client-side rendering in non-production environments to improve development experience.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
www/src/app.tsx (1)

17-20: Consider polishing the comment wording.

The comment effectively explains the reasoning, but "by the way" is somewhat informal for code documentation.

📝 Suggested revision
 /**
  * We have an SSG setup in production, so we want to hydrate the app.
- * In development by the way we just want to render it normally, to avoid hydration mismatches false positives.
+ * In development, we render normally to avoid false positive hydration mismatch warnings.
  */
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d84e34 and b0de9ce.

📒 Files selected for processing (1)
  • www/src/app.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{ts,tsx}: Never use any type (implicit or explicit) in TypeScript code
Prefer unknown over any and refine the type in TypeScript
Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions
Do not use as type assertions in TypeScript; the only exception is as const

All imports from recharts must use the public API entry point (e.g., import { TooltipIndex } from 'recharts'). Imports from internal paths like recharts/types/* or recharts/src/* are not allowed and will fail the linter.

Files:

  • www/src/app.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Ensure code lints by running npm run lint and follows Airbnb's Style Guide

Files:

  • www/src/app.tsx
🧠 Learnings (1)
📓 Common learnings
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6659
File: www/src/components/GuideView/Performance/index.tsx:232-250
Timestamp: 2025-11-19T14:08:01.728Z
Learning: In Recharts version 3.4.2, object-as-prop optimizations were introduced to reduce unnecessary re-renders when new object references are passed as props. This affects the recommendation for the `react-perf/jsx-no-new-object-as-prop` ESLint rule.
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to test/component/**/*.spec.tsx : Use React Testing Library for testing component interactions and behavior upon rendering
🧬 Code graph analysis (1)
www/src/app.tsx (3)
www/src/components/color-mode/ColorModeProvider.tsx (1)
  • ColorModeProvider (7-15)
www/src/components/color-mode/defineColorModeStore.ts (1)
  • defineColorModeStore (55-106)
www/src/containers/Root.tsx (1)
  • Root (5-12)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build, Test, Pack
🔇 Additional comments (3)
www/src/app.tsx (3)

1-1: LGTM! Correct imports for conditional rendering.

The addition of createRoot alongside hydrateRoot is appropriate for supporting both SSG hydration (production) and standard client-side rendering (development).


11-15: Good refactor to avoid duplication.

Extracting the React tree into a variable is sensible since it's used in both the production and development rendering paths.


21-25: Correct approach for environment-specific rendering.

The conditional logic properly addresses the issue described in the PR:

  • Production uses hydrateRoot to hydrate pre-rendered SSG content
  • Development uses createRoot for standard client-side rendering, avoiding false positive hydration warnings

This aligns with the stated goal of eliminating React warnings encountered during development.

@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.89%. Comparing base (de9381c) to head (b0de9ce).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
www/src/app.tsx 0.00% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6853      +/-   ##
==========================================
- Coverage   93.90%   93.89%   -0.01%     
==========================================
  Files         531      531              
  Lines       49429    49432       +3     
  Branches     5169     5169              
==========================================
  Hits        46415    46415              
- Misses       3007     3010       +3     
  Partials        7        7              

☔ 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.

@cloud-walker cloud-walker changed the title docs: improve app dev rendering fix: improve doc app dev rendering Jan 4, 2026
@PavelVanecek PavelVanecek merged commit 79f5daa into recharts:main Jan 5, 2026
35 of 37 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 11, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants