Skip to content

Commit 2304cd9

Browse files
memoize lazyloadView
1 parent 5a43440 commit 2304cd9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

client/packages/lowcoder/src/comps/comps/lazyLoadComp/lazyLoadComp.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import styled from "styled-components";
1111
import { RemoteCompInfo } from "types/remoteComp";
1212
import { withErrorBoundary } from "comps/generators/withErrorBoundary";
1313
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
14+
import React from "react";
1415

1516
const ViewError = styled.div`
1617
display: flex;
@@ -50,7 +51,7 @@ interface LazyCompViewProps {
5051
errorElement?: (error: any) => React.ReactNode;
5152
}
5253

53-
function LazyCompView(props: React.PropsWithChildren<LazyCompViewProps>) {
54+
const LazyCompView = React.memo((props: React.PropsWithChildren<LazyCompViewProps>) => {
5455
const { loadComp, loadingElement, errorElement } = props;
5556
const [error, setError] = useState<any>("");
5657
const currentTheme = useContext(ThemeContext)?.theme;
@@ -83,7 +84,7 @@ function LazyCompView(props: React.PropsWithChildren<LazyCompViewProps>) {
8384
return (
8485
<WhiteLoading />
8586
);
86-
}
87+
});
8788

8889
export type LazyloadCompLoader<T = RemoteCompInfo> = () => Promise<CompConstructor | null>;
8990

0 commit comments

Comments
 (0)