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

refactor(web): replace inline require with import #1206

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 5 additions & 17 deletions packages/core/src/LottieView/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@ import React, {
} from "react";
import { parsePossibleSources } from "./utils";
import { LottieViewProps } from "lottie-react-native";
import type {
import {
DotLottieCommonPlayer,
DotLottiePlayer,
PlayerEvents,
Props,
} from "@dotlottie/react-player";

let DotLottiePlayer: React.ForwardRefExoticComponent<
Props & React.RefAttributes<DotLottieCommonPlayer | null>
>;
try {
DotLottiePlayer = require("@dotlottie/react-player").DotLottiePlayer;
} catch (e) {}

const LottieView = forwardRef(
(
{
Expand Down Expand Up @@ -64,11 +57,11 @@ const LottieView = forwardRef(
(fn: () => void) => {
if (!isReady) {
const container = playerRef.current?.container;
const listerner = () => {
const listener = () => {
fn();
container?.removeEventListener("is_ready", listerner);
container?.removeEventListener("is_ready", listener);
};
container?.addEventListener("is_ready", listerner);
container?.addEventListener("is_ready", listener);
} else {
fn();
}
Expand Down Expand Up @@ -161,11 +154,6 @@ const LottieView = forwardRef(
[isReady]
);

if (!DotLottiePlayer) {
throw new Error(
"lottie-react-native: The module @dotlottie/react-player is missing."
);
}
return (
<DotLottiePlayer
key={key}
Expand Down