@@ -88,7 +88,6 @@ function LightningSparks({
8888// Shows a plug that animates through the connection process.
8989export function ConnectionPlug ( ) {
9090 const isConnected = useIsAConnectionConnected ( ) ;
91- const animationStartTime = useRef < number > ( Date . now ( ) ) ;
9291 const animationFrameRef = useRef < number | null > ( null ) ;
9392
9493 // 0 = disconnected/animation start, 1 = connected/animation complete.
@@ -100,16 +99,15 @@ export function ConnectionPlug() {
10099 const cancelOngoingAnimation = ( ) => {
101100 if ( animationFrameRef . current ) {
102101 cancelAnimationFrame ( animationFrameRef . current ) ;
103- animationFrameRef . current = null ;
104102 }
105103 } ;
106104
107105 if ( isConnected ) {
108106 cancelOngoingAnimation ( ) ;
109- animationStartTime . current = Date . now ( ) ;
107+ const animationStartTime = Date . now ( ) ;
110108
111109 const animate = ( ) => {
112- const elapsed = Date . now ( ) - animationStartTime . current ;
110+ const elapsed = Date . now ( ) - animationStartTime ;
113111 const rawProgress = Math . min (
114112 elapsed / CONNECT_ANIMATION_DURATION_MS ,
115113 1
@@ -129,10 +127,10 @@ export function ConnectionPlug() {
129127 } else if ( ! isConnected ) {
130128 cancelOngoingAnimation ( ) ;
131129 // Quick disconnect animation.
132- animationStartTime . current = Date . now ( ) ;
130+ const animationStartTime = Date . now ( ) ;
133131
134132 const animate = ( ) => {
135- const elapsed = Date . now ( ) - animationStartTime . current ;
133+ const elapsed = Date . now ( ) - animationStartTime ;
136134 const rawProgress = Math . min (
137135 elapsed / DISCONNECT_ANIMATION_DURATION_MS ,
138136 1
0 commit comments