Skip to content

Added memoization to minimize re-rendering #1159

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

Merged
merged 9 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed table not loading inside kanban card
  • Loading branch information
raheeliftikhar5 committed Sep 12, 2024
commit cd948afee2b306f929cbfcff3cbeb13eb229d42c
17 changes: 10 additions & 7 deletions client/packages/lowcoder/src/comps/controls/slotControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { createContext, useContext } from "react";
import styled from "styled-components";
import { NameGenerator } from "comps/utils";
import { JSONValue } from "util/jsonTypes";
import React from "react";
import { isEqual } from "lodash";

const ModalStyled = styled.div<{ $background?: string }>`
.ant-modal-content {
Expand All @@ -42,23 +44,23 @@ export const SlotConfigContext = createContext<{
modalWidth: 520,
});

const ContainerView = (props: ContainerBaseProps) => {
const ContainerView = React.memo((props: ContainerBaseProps) => {
return <InnerGrid {...props} emptyRows={15} autoHeight />;
};
});

function ModalConfigView(props: {
const ModalConfigView = React.memo((props: {
visible: boolean;
containerProps: ConstructorToView<typeof SimpleContainerComp>;
onCancel: () => void;
}) {
}) => {
const { visible, containerProps, onCancel } = props;
const background = useContext(BackgroundColorContext);
const { modalWidth = 520 } = useContext(SlotConfigContext);
if (!visible) {
return null;
}
return (
(<ModalWrapper>
<ModalWrapper>
<Modal
width={modalWidth}
open={visible}
Expand All @@ -67,6 +69,7 @@ function ModalConfigView(props: {
footer={null}
styles={{ body: {padding: "0"} }}
zIndex={Layers.modal}
maskClosable={false}
modalRender={(node) => (
<ModalStyled $background={background} onClick={() => {}}>
{node}
Expand All @@ -81,9 +84,9 @@ function ModalConfigView(props: {
items={gridItemCompToGridItems(containerProps.items)}
/>
</Modal>
</ModalWrapper>)
</ModalWrapper>
);
}
}, (prevProps, nextProps) => isEqual(prevProps, nextProps));

const childrenMap = {
container: SimpleContainerComp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export function withSelectedMultiContext<TCtor extends MultiCompConstructor>(
|| isCustomAction<LazyCompReadyAction>(action, "LazyCompReady")
|| isCustomAction<ModuleReadyAction>(action, "moduleReady")
) && action.path[1] === SELECTED_KEY) {
if (action.path[0] === MAP_KEY && action.path[1] === SELECTED_KEY) {
action.path[1] = this.selection;
comp = super.reduce(action);
}
// broadcast
const newAction = {
...action,
Expand Down