This page provides guidance for migrating your code when upgrading between major versions of Recharts.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/recharts/recharts/llms.txt
Use this file to discover all available pages before exploring further.
Version 2.0.0
TypeScript rewrite
Version 2.0.0 was completely rewritten in TypeScript. This provides better type safety and improved developer experience. What changed:- Source code is now TypeScript (
src/contains.tsand.tsxfiles) - Full type definitions included
- Better autocomplete and type checking in TypeScript projects
- Update your TypeScript types if you were using custom type definitions
- Remove any community-provided type packages like
@types/recharts
React version requirement
What changed:- Only React 16+ is supported
- React 15 support has been removed
- Upgrade to React 16 or higher before upgrading Recharts
- Replace unsafe lifecycle methods if you’re using custom components
Component lifecycle changes
Component lifecycle changes
Version 2.0.0 uses
getDerivedStateFromProps to replace UNSAFE_componentWillReceiveProps for React 17 support.If you’re using custom components with Recharts, ensure they’re compatible with React 16+ lifecycle methods.D3 package upgrades
What changed:- D3 packages (d3-scale, d3-shape, d3-interpolate) upgraded to version 2.x/3.x
- D3 7.x upgrade in version 2.1.12 may break some testing tools
Jest configuration for D3 7.x (v2.1.12+)
Jest configuration for D3 7.x (v2.1.12+)
If you’re using Jest for testing, you may need to update your configuration:
Prop changes
Pie component
Pie component
What changed:
- Deprecated
valueKeyprop removed
- Use
dataKeyinstead ofvalueKey
Axis components
Axis components
What changed:
scale="utcTime"renamed toscale="utc"
- Update scale prop values
Stack offset changes
What changed:- Fixed
stackOffset="sign"behavior - Added
stackOffset="positive"option for positive-only stacking
- Review your stacked charts with
stackOffset="sign"to ensure they still display correctly - Use
stackOffset="positive"if you need the old behavior for positive values only
Type exports
What changed:- Component props are now exported for TypeScript users
- Update imports if you were defining types manually
Version 1.0.0
Breaking changes from 0.x
Legend and Tooltip wrapperStyle
Legend and Tooltip wrapperStyle
What changed:
- Removed
wrapperStyleprop from DefaultTooltipContent
- Use
contentStyleprop instead for styling tooltip content
Axis scale values
Axis scale values
What changed:
- Replaced axis scale value
utcTimewithutc
- Update any XAxis or YAxis components using
scale="utcTime"
Line and Area clipping
Line and Area clipping
What changed:
- Dots in Line charts are now clipped by default
- Verify that your line charts display as expected
- Adjust margins if needed to show dots at chart boundaries
Need help?
If you encounter issues during migration:- Check the GitHub Issues for similar problems
- Review the full changelog for detailed changes
- Ask questions in GitHub Discussions
- Join the Recharts Slack community