Skip to content

Some more performance improvements#6654

Merged
ckifer merged 9 commits intomainfrom
line-perf
Nov 18, 2025
Merged

Some more performance improvements#6654
ckifer merged 9 commits intomainfrom
line-perf

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Nov 18, 2025

Description

In #6624 and other issues I noticed that people tend to define things inline - which is no surprise because our docs and examples recommend that too.

We can memoize the object props with a small custom method so I did that, looks like it works well.

We can't do much with inline functions and inline elements, memoization won't work there. v2 just plain ignores them which I don't think we want to do anymore.

So I found this react perf plugin which flags exactly what we need so I added it too and ran against this one example.

Plus some supporting changes in the website navigation list, and allowing some syntax in ESLint config.

I will later summarize it in a perf guide, but that will be in next PR.

Related Issue

#6624

How Has This Been Tested?

Devtools

Before & after video (with 6x slowdown)

Screen.Recording.2025-11-18.at.23.29.38.mov

One render cycle during mouse move

Before - notice the high animation count - it was re-calculating the animation on each mouse move. Also, multiple components render again and again.

Screenshot 2025-11-18 at 17 36 05

After - notice low animation count, and most components never render. Other than Tooltip and ReferenceLine which have to render because they change position on mouse move.

Screenshot 2025-11-18 at 23 33 03

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

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 98.98063% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.26%. Comparing base (8d09b37) to head (10bac72).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...cs/exampleComponents/LineChart/CompareTwoLines.tsx 99.08% 8 Missing ⚠️
src/util/axisPropsAreEqual.ts 92.59% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6654      +/-   ##
==========================================
+ Coverage   94.17%   94.26%   +0.09%     
==========================================
  Files         494      496       +2     
  Lines       41644    42442     +798     
  Branches     4819     4858      +39     
==========================================
+ Hits        39218    40009     +791     
- Misses       2421     2428       +7     
  Partials        5        5              

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

@PavelVanecek
Copy link
Collaborator Author

@ckifer I can break this down to smaller PRs if you prefer. There are couple of changes that could go out on its own.

@codecov
Copy link

codecov bot commented Nov 18, 2025

Bundle Report

Changes will increase total bundle size by 6.26kB (0.24%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.14MB 2.81kB (0.25%) ⬆️
recharts/bundle-es6 981.37kB 2.62kB (0.27%) ⬆️
recharts/bundle-umd 514.56kB 825 bytes (0.16%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/Area.js 85 bytes 27.69kB 0.31%
cartesian/Bar.js 85 bytes 27.09kB 0.31%
cartesian/Line.js 85 bytes 25.97kB 0.33%
cartesian/Scatter.js 85 bytes 23.99kB 0.36%
cartesian/CartesianAxis.js -587 bytes 16.9kB -3.36%
cartesian/YAxis.js -703 bytes 8.99kB -7.25%
cartesian/XAxis.js -703 bytes 7.49kB -8.58%
util/svgPropertiesNoEvents.js -51 bytes 7.05kB -0.72%
util/propsAreEqual.js (New) 2.81kB 2.81kB 100.0% 🚀
util/svgPropertiesAndEvents.js -50 bytes 2.36kB -2.08%
util/axisPropsAreEqual.js (New) 2.0kB 2.0kB 100.0% 🚀
state/referenceElementsSlice.js 54 bytes 1.85kB 3.01%
state/ReportMainChartProps.js 190 bytes 1.59kB 13.52% ⚠️
util/ShallowEqual.js (Deleted) -493 bytes 0 bytes -100.0% 🗑️
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 825 bytes 514.56kB 0.16%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/Area.js 70 bytes 25.82kB 0.27%
cartesian/Bar.js 70 bytes 25.38kB 0.28%
cartesian/Line.js 70 bytes 24.41kB 0.29%
cartesian/Scatter.js 70 bytes 22.41kB 0.31%
cartesian/CartesianAxis.js -549 bytes 15.64kB -3.39%
cartesian/YAxis.js -684 bytes 7.7kB -8.16%
util/svgPropertiesNoEvents.js -51 bytes 6.77kB -0.75%
cartesian/XAxis.js -684 bytes 6.29kB -9.8%
util/propsAreEqual.js (New) 2.69kB 2.69kB 100.0% 🚀
util/svgPropertiesAndEvents.js -50 bytes 2.08kB -2.35%
util/axisPropsAreEqual.js (New) 1.86kB 1.86kB 100.0% 🚀
state/ReportMainChartProps.js 152 bytes 1.37kB 12.48% ⚠️
state/referenceElementsSlice.js 46 bytes 1.3kB 3.66%
util/ShallowEqual.js (Deleted) -383 bytes 0 bytes -100.0% 🗑️

@ckifer
Copy link
Member

ckifer commented Nov 18, 2025

easy enough review, all good. LGTM

@ckifer ckifer merged commit d2ff4b6 into main Nov 18, 2025
28 checks passed
@ckifer ckifer deleted the line-perf branch November 18, 2025 16:58
ckifer pushed a commit that referenced this pull request Nov 24, 2025
…6677)

## Description

`eslint-plugin-react-perf` was incorrectly placed in `dependencies`
instead of `devDependencies`, causing the entire ESLint toolchain to be
installed in downstream projects using Recharts.

The plugin is only used in `eslint.config.mjs` for enforcing performance
rules during development:

```javascript
const perfOptimization = {
  name: 'perf-optimization-examples',
  files: ['./www/src/docs/exampleComponents/LineChart/CompareTwoLines.tsx'],
  plugins: { 'react-perf': reactPerf },
  rules: {
    'react-perf/jsx-no-new-array-as-prop': 'error',
    'react-perf/jsx-no-new-function-as-prop': 'error',
    'react-perf/jsx-no-jsx-as-prop': 'error',
  },
};
```

## Related Issue

Fixes #6675

## Motivation and Context

Production applications should not install development-only tooling.
Moving this to `devDependencies` prevents unnecessary bloat in
downstream projects while maintaining functionality for Recharts
development.

## How Has This Been Tested?

- Verified linting works: `npm run lint`
- Verified build completes: `npm run build`
- All unit tests pass: 3437 tests

## Screenshots (if appropriate):

N/A

## Types of changes

- [x] 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

<!-- START COPILOT CODING AGENT SUFFIX -->



<details>

<summary>Original prompt</summary>

> 
> ----
> 
> *This section details on the original issue you should resolve*
> 
> <issue_title>[3.5.0] recharts now installs
eslint-plugin-react-perf</issue_title>
> <issue_description>## What is the current behavior?
> 
> `recharts@3.5.0` has `eslint-plugin-react-perf` as a dependncy.
> It was added by #6654
> This causes this dependency, and entire eslint toolchain, to get
installed in downstream projects
> 
> ## What is the expected behavior?
> 
> `eslint-plugin-react-perf` should be a devDependency, as it's only
used by repository's own development flow.
> 
> ## Steps to reproduce
> 
> ```
> mkdir recharts-eslint-dep
> cd recharts-eslint-dep
> npm init -y
> npm i recharts
> npm why eslint
> ```</issue_description>
> 
> ## Comments on the Issue (you are @copilot in this section)
> 
> <comments>
> <comment_new><author>@PavelVanecek</author><body>
> Thanks @AviVahl yeah this definitely should have been a
devdependency.</body></comment_new>
> </comments>
> 


</details>

- Fixes #6675

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PavelVanecek <1100170+PavelVanecek@users.noreply.github.com>
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