Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix suspense boundry #1448

Merged
merged 4 commits into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading