Open KayvanShah1 opened 3 months ago
Same problem
Did anyone find a fix? I am experiencing the same issue.
Did anyone find a fix? I am experiencing the same issue.
One possible solution is to downgrade the node to 20.x and reinstall node modules
The reason this issue is popping up is because of NextJS Server-Side Rendering (SSR) nature, while Lottie utilizes the window object which is not available during SSR, causing the build to fail.
To fix the issue, simply change the code in BentoGrid.tsx for the importing of the lottie library:
import dynamic from 'next/dynamic';
const Lottie = dynamic(() => import('react-lottie'), { ssr: false });
Credits to: Dragos UniqQum
Edit-1: I noticed that using this method will lead to a forEach error, therefore, to resolve that error, try using an alternative library in the name of react-lottie-player which has almost similar options with minor modifications required.
Code with modifications:
import dynamic from 'next/dynamic';
const Lottie = dynamic(() => import('react-lottie-player'), { ssr: false });
<div className={`absolute -bottom-5 right-[5.75rem]`}>
<Lottie
loop={false}
animationData={animationData}
play={copied}
rendererSettings={{
preserveAspectRatio: 'xMidYMid slice'
}}
style={{ height: 300, width: 200 }}
/>
</div>
Tried dynamic loading with useEffect Hook