Skip to content

Commit 387756b

Browse files
authored
[26기] SSR 환경에서 lottie-web Import시 발생하는 오류 수정 (#190)
2 parents 1f3390b + 7fcc141 commit 387756b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

components/home/AnimatedTextSection/index.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
RECRUIT_BANNER,
88
RECRUIT_BANNER_ACTIVE,
99
} from 'database/recruit';
10-
import lottie from 'lottie-web';
10+
1111
import { useRouter } from 'next/router';
1212
import type { ReactElement } from 'react';
1313
import { useEffect, useRef } from 'react';
@@ -22,13 +22,18 @@ function AnimatedTextSection(): ReactElement {
2222

2323
const router = useRouter();
2424
useEffect(() => {
25-
lottie.loadAnimation({
26-
container: animatedTextRef.current as HTMLDivElement,
27-
renderer: 'svg',
28-
loop: true,
29-
autoplay: true,
30-
animationData: require('public/assets/lottie/motion.json'),
31-
});
25+
const loadAnimation = async () => {
26+
const lottie = await import('lottie-web');
27+
const animationData = await import('public/assets/lottie/motion.json');
28+
lottie.default.loadAnimation({
29+
container: animatedTextRef.current as HTMLDivElement,
30+
renderer: 'svg',
31+
loop: true,
32+
autoplay: true,
33+
animationData: animationData.default,
34+
});
35+
};
36+
loadAnimation();
3237
}, []);
3338

3439
return (

0 commit comments

Comments
 (0)