Skip to content

Commit

Permalink
Lottie fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoplowe committed Nov 22, 2024
2 parents a607c90 + 4007c15 commit 989b701
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/components/Lottie/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import React from "react";
import Lottie from "lottie-react";

import React, { Suspense, lazy } from "react";
import BrowserOnly from "@docusaurus/BrowserOnly";

import styles from "./styles.module.scss";

// Dynamically import the Lottie component
const Lottie = lazy(() => import("lottie-react"));

const App = (props) => {
const {
animation,
loop=true,
loop = true,
...rest
} = props
} = props;

return <BrowserOnly>
{ () =>
<Lottie
className={styles.wrapper}
animationData={animation}
loop={loop}
{...rest}
/>}
</BrowserOnly>
return (
<BrowserOnly>
{() => (
<Suspense fallback={<div>Loading...</div>}>
<Lottie
className={styles.wrapper}
animationData={animation}
loop={loop}
{...rest}
/>
</Suspense>
)}
</BrowserOnly>
);
};

export default App;
export default App;

0 comments on commit 989b701

Please sign in to comment.