Skip to content

Commit

Permalink
Merge pull request #611 from psarando/dynamic-loading-animation
Browse files Browse the repository at this point in the history
Use `await import` for `lottie-web` in LoadingAnimation
  • Loading branch information
psarando authored Dec 9, 2024
2 parents 1ef6170 + de22625 commit ff9b9b9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/components/vice/loading/LoadingAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import React, { useEffect, useRef } from "react";

import { makeStyles } from "tss-react/mui";
import lottie from "lottie-web";
import animation from "./vice_loading.json";

import styles from "./styles";
Expand All @@ -17,13 +16,17 @@ function LoadingAnimation() {
const { classes } = useStyles();

useEffect(() => {
lottie.loadAnimation({
container: animationContainer.current,
renderer: "svg",
loop: true,
autoplay: true,
animationData: animation,
});
const loadAnimation = async () => {
const lottie = (await import("lottie-web")).default;
lottie.loadAnimation({
container: animationContainer.current,
renderer: "svg",
loop: true,
autoplay: true,
animationData: animation,
});
};
loadAnimation();
}, []);

return <div className={classes.animationBox} ref={animationContainer} />;
Expand Down

0 comments on commit ff9b9b9

Please sign in to comment.