Skip to content

Commit 1cf868e

Browse files
fix memoization issues
1 parent a80dae6 commit 1cf868e

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,18 @@ const UIView = React.memo((props: {
384384
]);
385385

386386
// render condition for modal and drawer as we are not getting compType here
387-
388-
const uiCompRender = useMemo(() => props.viewFn(childrenProps, comp.dispatch), [
389-
childrenProps,
390-
comp.dispatch
391-
]);
392-
393-
const uiCompRenderWithWrapper = useMemo(() => {
387+
if (comp.children.hasOwnProperty('showMask') && comp.children.hasOwnProperty('maskClosable')) {
394388
return (
389+
<HidableView hidden={childrenProps.hidden as boolean}>
390+
{props.viewFn(
391+
childrenProps,
392+
comp.dispatch
393+
)}
394+
</HidableView>
395+
);
396+
}
397+
398+
return (
395399
<div
396400
ref={props.innerRef}
397401
className={childrenProps.className as string}
@@ -400,30 +404,14 @@ const UIView = React.memo((props: {
400404
width: '100%',
401405
height: '100%',
402406
margin: '0px',
403-
padding: getPadding()
407+
padding: getPadding(),
404408
}}
405409
>
406-
{uiCompRender}
410+
<HidableView hidden={childrenProps.hidden as boolean}>
411+
{props.viewFn(childrenProps, comp.dispatch)}
412+
</HidableView>
407413
</div>
408-
)}, [
409-
uiCompRender,
410-
props.innerRef,
411-
childrenProps.className,
412-
childrenProps.dataTestId,
413-
getPadding,
414-
]);
415-
416-
const renderView = useMemo(() => {
417-
if (
418-
comp.children.hasOwnProperty('showMask')
419-
&& comp.children.hasOwnProperty('maskClosable')
420-
) {
421-
return uiCompRender;
422-
}
423-
return uiCompRenderWithWrapper;
424-
}, [comp.children]);
425-
426-
return renderView;
414+
);
427415
}, (prevProps, nextProps) => {
428416
return isEqual(prevProps, nextProps);
429417
});

0 commit comments

Comments
 (0)