Skip to content

Commit

Permalink
fix: memoize LayoutSystemBasedCanvas
Browse files Browse the repository at this point in the history
  • Loading branch information
marks0351 committed Sep 26, 2023
1 parent f9c6395 commit 081c68b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/client/src/layoutSystems/CanvasFactory.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from "react";
import React, { memo, useMemo } from "react";
import { useSelector } from "react-redux";
import {
getAppPositioningType,
Expand All @@ -15,7 +15,8 @@ import { getLayoutSystem } from "./withLayoutSystemWidgetHOC";
* Canvas also provides editing layout system specific editing experiences like Drag and Drop, Drag to Select, Widget Grouping, etc.
* This Component Hydrates canvas with enhanced properties from withWidgetProps and picks the layout system specific Canvas Implementation.
*/
const LayoutSystemBasedCanvas = withWidgetProps(((props: WidgetProps) => {

const LayoutSystemBasedCanvas = memo((props: WidgetProps) => {
const renderMode = useSelector(getRenderMode);
const appPositioningType = useSelector(getAppPositioningType);
const { canvasSystem } = useMemo(
Expand All @@ -29,8 +30,12 @@ const LayoutSystemBasedCanvas = withWidgetProps(((props: WidgetProps) => {
);
const { Canvas, propertyEnhancer } = canvasSystem;
return <Canvas {...propertyEnhancer(props)} />;
}) as any);
});

const HydratedLayoutSystemBasedCanvas = withWidgetProps(
LayoutSystemBasedCanvas as any,
);

export const renderAppsmithCanvas = (props: WidgetProps) => {
return <LayoutSystemBasedCanvas {...props} />;
return <HydratedLayoutSystemBasedCanvas {...props} />;
};

0 comments on commit 081c68b

Please sign in to comment.