Skip to content

Commit dd105eb

Browse files
lazy load ReactPlayer + ReactMarkdown
1 parent 4909da2 commit dd105eb

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

client/packages/lowcoder-design/src/components/audio.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { CSSProperties } from "react";
2-
import { Ref } from "react";
3-
import ReactPlayer from "react-player";
2+
import { lazy, Ref } from "react";
3+
import type {default as ReactPlayerType} from "react-player";
44
import styled from "styled-components";
55

6+
const ReactPlayer = lazy(() => import("react-player"));
7+
68
const Audio = styled(ReactPlayer)`
79
height: 32px !important;
810
`;
@@ -14,7 +16,7 @@ export function TacoAudio(props: {
1416
onEnded?: () => void;
1517
className?: string;
1618
style?: CSSProperties;
17-
audioRef?: Ref<ReactPlayer>;
19+
audioRef?: Ref<ReactPlayerType>;
1820
autoPlay?: boolean;
1921
loop?: boolean;
2022
}) {

client/packages/lowcoder-design/src/components/markdown.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { css } from "styled-components";
2-
import ReactMarkdown from "react-markdown";
2+
import { lazy } from "react";
3+
// import ReactMarkdown from "react-markdown";
34
import rehypeRaw from "rehype-raw";
45
import rehypeSanitize, { defaultSchema } from "rehype-sanitize";
56
import remarkGfm from "remark-gfm";
6-
import { ReactMarkdownOptions } from "react-markdown/lib/react-markdown";
7+
import type { ReactMarkdownOptions } from "react-markdown/lib/react-markdown";
8+
9+
const ReactMarkdown = lazy(() => import('react-markdown'));
710

811
export const markdownCompCss = css`
912
.markdown-body {

client/packages/lowcoder-design/src/components/video.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import ReactPlayer from "react-player";
1+
// import ReactPlayer from "react-player";
2+
import { lazy } from 'react';
23
import styled from "styled-components";
34
import { videoPlayTriangle } from "icons";
45

6+
const ReactPlayer = lazy(() => import("react-player"));
7+
58
export const Video = styled(ReactPlayer)`
69
height: 100% !important;
710
width: 100% !important;

0 commit comments

Comments
 (0)