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 Build Error by Implementing Conditional Dynamic Import for Lottie #14

Closed
wants to merge 1 commit into from

Conversation

mohsn-mirzaei
Copy link

Summary

This pull request fixes a build error by implementing a conditional dynamic import for Lottie.

Details

  • Changed: Replaced the static import of Lottie with a conditional dynamic import based on the environment.
  • Development Environment: Used require for importing Lottie when NODE_ENV is set to "development".
  • Production Environment: Used next/dynamic for importing Lottie with SSR disabled.

Changes

// Previous import
import Lottie from "react-lottie";

// New imports
import dynamic from "next/dynamic";
let Lottie;

if (process.env.NODE_ENV === "development") {
  Lottie = require("react-lottie").default;
} else {
  Lottie = dynamic(() => import("react-lottie"), { ssr: false });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant