@@ -20,8 +20,8 @@ export interface AnimatedLineProps extends React.ComponentPropsWithoutRef<'path'
20
20
}
21
21
22
22
const DURATION = 200 ;
23
- function useLineAnimatedProps ( props : Pick < AnimatedLineProps , 'd' | 'skipAnimation' > ) {
24
- const lastValues = React . useRef ( { d : props . d } ) ;
23
+ function useAnimatePath ( props : Pick < AnimatedLineProps , 'd' | 'skipAnimation' > ) {
24
+ const lastDRef = React . useRef ( props . d ) ;
25
25
const transitionRef = React . useRef < Transition < SVGPathElement , unknown , null , undefined > > ( null ) ;
26
26
const [ path , setPath ] = React . useState < SVGPathElement | null > ( null ) ;
27
27
@@ -31,7 +31,7 @@ function useLineAnimatedProps(props: Pick<AnimatedLineProps, 'd' | 'skipAnimatio
31
31
return ;
32
32
}
33
33
34
- const lastD = lastValues . current . d ;
34
+ const lastD = lastDRef . current ;
35
35
const stringInterpolator = interpolateString ( lastD , props . d ) ;
36
36
37
37
transitionRef . current = select ( path )
@@ -40,7 +40,7 @@ function useLineAnimatedProps(props: Pick<AnimatedLineProps, 'd' | 'skipAnimatio
40
40
. attrTween ( 'd' , ( ) => ( t ) => {
41
41
const interpolatedD = stringInterpolator ( t ) ;
42
42
43
- lastValues . current = { d : interpolatedD } ;
43
+ lastDRef . current = interpolatedD ;
44
44
45
45
return interpolatedD ;
46
46
} ) ;
@@ -66,13 +66,14 @@ const AnimatedLine = React.forwardRef<SVGPathElement, AnimatedLineProps>(
66
66
function AnimatedLine ( props , ref ) {
67
67
const { d, skipAnimation, ownerState, ...other } = props ;
68
68
69
- const animateRef = useLineAnimatedProps ( props ) ;
69
+ const animateRef = useAnimatePath ( props ) ;
70
70
const forkRef = useForkRef ( ref , animateRef ) ;
71
71
72
72
return (
73
73
< AppearingMask skipAnimation = { skipAnimation } id = { `${ ownerState . id } -line-clip` } >
74
74
< path
75
75
ref = { forkRef }
76
+ // TODO: Removed `d` prop from the since `useAnimatePath` is handling it. Not sure how this impacts SSR, though.
76
77
stroke = { ownerState . gradientId ? `url(#${ ownerState . gradientId } )` : ownerState . color }
77
78
strokeWidth = { 2 }
78
79
strokeLinejoin = "round"
0 commit comments