Skip to content

Commit 01273fb

Browse files
authored
fix: donation svg animation (freeCodeCamp#57867)
1 parent 234aa80 commit 01273fb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

client/src/components/Donation/donation-modal-body.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { useEffect, useState, useRef } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { useFeature } from '@growthbook/growthbook-react';
44
import { Col, Row, Modal, Spacer } from '@freecodecamp/ui';
@@ -129,7 +129,9 @@ const AnimationContainer = ({
129129
}: {
130130
secondsRemaining: number;
131131
}) => {
132+
const animationKey = useRef(Date.now()).current;
132133
const newBearAnimation = useFeature('new-bear-animation').on;
134+
const animationSrc = `${newBearAnimation ? donationAnimationB : donationAnimation}?t=${animationKey}`;
133135
const { t } = useTranslation();
134136
return (
135137
<>
@@ -174,9 +176,9 @@ const AnimationContainer = ({
174176
)}
175177
</div>
176178
<img
177-
key={Date.now()}
179+
key={animationKey}
178180
alt=''
179-
src={newBearAnimation ? donationAnimationB : donationAnimation}
181+
src={animationSrc}
180182
id={'donation-animation'}
181183
data-playwright-test-label='donation-animation'
182184
/>

0 commit comments

Comments
 (0)