-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[charts] Fix LineChart
transition stopping before completion
#14366
[charts] Fix LineChart
transition stopping before completion
#14366
Conversation
Deploy preview: https://deploy-preview-14366--material-ui-x.netlify.app/ |
CodSpeed Performance ReportMerging #14366 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice, but it still causes issues when adding/removing a line to the chart
Capture.video.du.2024-08-27.18-07-00.mp4
https://deploy-preview-14366--material-ui-x.netlify.app/x/react-charts/lines/#animation
@@ -3,27 +3,39 @@ import { interpolateString } from '@mui/x-charts-vendor/d3-interpolate'; | |||
import { useSpring, to } from '@react-spring/web'; | |||
|
|||
function usePrevious<T>(value: T) { | |||
const ref = React.useRef<T | null>(null); | |||
const ref = React.useRef<{ current: T; previous?: T }>({ | |||
current: value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe renaming it with actual
or currentValue
to avoid the confusion with the current
of the ref
We were using |
These two seem to be unrelated though: #14355 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Verified that it fixes #12873
https://codesandbox.io/p/sandbox/exciting-wright-m4s345?file=%2Fpackage.json%3A6%2C82
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to see this fixed 🎉
I don't see any issue 👍
Fixes #12873
Closes #12892
Fixes original issue: https://codesandbox.io/p/sandbox/solitary-cookies-2k447w?file=%2Fsrc%2FDemo.tsx%3A7%2C1&workspaceId=836800c1-9711-491c-a89b-3ac24cbd8cd8
And example issue opened on react-spring
https://stackblitz.com/edit/vitejs-vite-9sj21g?file=src%2FApp.tsx