diff --git a/packages/x-charts/src/LineChart/MarkElement.tsx b/packages/x-charts/src/LineChart/MarkElement.tsx index 137f44f252b7..b86ef162168d 100644 --- a/packages/x-charts/src/LineChart/MarkElement.tsx +++ b/packages/x-charts/src/LineChart/MarkElement.tsx @@ -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, diff --git a/packages/x-charts/src/internals/useAnimatedPath.ts b/packages/x-charts/src/internals/useAnimatedPath.ts index 9f29447fe138..03b0470b0db0 100644 --- a/packages/x-charts/src/internals/useAnimatedPath.ts +++ b/packages/x-charts/src/internals/useAnimatedPath.ts @@ -1,29 +1,42 @@ 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(value: T) { - const ref = React.useRef(null); - React.useEffect(() => { - ref.current = value; - }, [value]); + const ref = React.useRef<{ currentPath: T; previousPath?: T }>({ + currentPath: value, + previousPath: undefined, + }); + if (ref.current.currentPath !== value) { + ref.current = { + currentPath: value, + previousPath: ref.current.currentPath, + }; + } + return ref.current; } -// Taken from Nivo export const useAnimatedPath = (path: string, skipAnimation?: boolean) => { - const previousPath = usePrevious(path); + const memoryRef = usePrevious(path); + const interpolator = React.useMemo( - () => (previousPath ? interpolateString(previousPath, path) : () => path), - [previousPath, path], + () => + memoryRef.previousPath + ? interpolateString(memoryRef.previousPath, memoryRef.currentPath) + : () => memoryRef.currentPath, + [memoryRef.currentPath, memoryRef.previousPath], ); - const { value } = useSpring({ - from: { value: 0 }, - to: { value: 1 }, - reset: true, - immediate: skipAnimation, - }); + const [{ value }] = useSpring( + { + from: { value: 0 }, + to: { value: 1 }, + reset: true, + immediate: skipAnimation, + }, + [memoryRef.currentPath], + ); - return to([value], interpolator); + return value.to(interpolator); }; diff --git a/scripts/githubActions/orderIdValidation.js b/scripts/githubActions/orderIdValidation.js index 1acc23cc1d00..c98fea6e9722 100644 --- a/scripts/githubActions/orderIdValidation.js +++ b/scripts/githubActions/orderIdValidation.js @@ -22,11 +22,15 @@ module.exports = async ({ core, context, github }) => { } else { const order = await fetch(`${orderApi}${orderId}`, { headers: { - Authorization: orderApiToken, + Authorization: `Basic ${orderApiToken}`, 'User-Agent': 'MUI-Tools-Private/X-Orders-Inspector v1', }, }); + if (!order.ok) { + core.info(`Request to ${orderApi} failed. Response status code: ${order.status}.`); + } + const orderDetails = await order.json(); core.debug(`>>> Order Items: ${orderDetails.line_items?.join(',')}`);