Skip to content

Commit

Permalink
rename object keys
Browse files Browse the repository at this point in the history
  • Loading branch information
JCQuintas committed Aug 27, 2024
1 parent 8da5695 commit 551209b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/x-charts/src/LineChart/MarkElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function MarkElement(props: MarkElementProps) {
});
const { axis } = React.useContext(InteractionContext);

const position = useSpring({ x, y, immediate: skipAnimation });
const position = useSpring({ to: { x, y }, immediate: skipAnimation });
const ownerState = {
id,
classes: innerClasses,
Expand Down
24 changes: 12 additions & 12 deletions packages/x-charts/src/internals/useAnimatedPath.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as React from 'react';
import { interpolateString } from '@mui/x-charts-vendor/d3-interpolate';
import { useSpring, to } from '@react-spring/web';
import { useSpring } from '@react-spring/web';

function usePrevious<T>(value: T) {
const ref = React.useRef<{ current: T; previous?: T }>({
current: value,
previous: undefined,
const ref = React.useRef<{ currentPath: T; previousPath?: T }>({
currentPath: value,
previousPath: undefined,
});
React.useEffect(() => {
ref.current = {
current: value,
previous: ref.current.current,
currentPath: value,
previousPath: ref.current.currentPath,
};
}, [value]);
return ref.current;
Expand All @@ -21,10 +21,10 @@ export const useAnimatedPath = (path: string, skipAnimation?: boolean) => {

const interpolator = React.useMemo(
() =>
memoryRef.previous
? interpolateString(memoryRef.previous, memoryRef.current)
: () => memoryRef.current,
[memoryRef],
memoryRef.previousPath
? interpolateString(memoryRef.previousPath, memoryRef.currentPath)
: () => memoryRef.currentPath,
[memoryRef.currentPath, memoryRef.previousPath],
);

const [{ value }] = useSpring(
Expand All @@ -34,8 +34,8 @@ export const useAnimatedPath = (path: string, skipAnimation?: boolean) => {
reset: true,
immediate: skipAnimation,
},
[memoryRef.current],
[memoryRef.currentPath],
);

return to([value], interpolator);
return value.to(interpolator);
};

0 comments on commit 551209b

Please sign in to comment.