Skip to content

Commit

Permalink
fix: added memoization for data provider callback
Browse files Browse the repository at this point in the history
  • Loading branch information
surajair committed Nov 26, 2024
1 parent d9f11d1 commit 28a895b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/components/canvas/static/AsyncPropsBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export default function AsyncPropsBlock(props: {
block: ChaiBlock;
dataProvider: (args: any) => any;
}) {
const dataProps = useMemo(() => props?.dataProvider({ block: props.block }), [props]);
const { dataProvider, block } = props;
const dataProps = useMemo(() => {
if (!dataProvider) return {};
return dataProvider({ block });
}, [block, dataProvider]);
return <Suspense>{React.createElement(props.component, { ...props.props, ...dataProps })}</Suspense>;
}

0 comments on commit 28a895b

Please sign in to comment.