import GridLayout, { WidthProvider } from 'react-grid-layout'; import { useSlotRecipe, chakra, Flex } from '@chakra-ui/react'; export default function MyDashboard({layout, onLayoutChange, isEditable, isDelete, DeleteWidget, widgetArray}) { console.log("rendering MyDashboard"); const recipe = useSlotRecipe({ key: "widget" }); const styles = recipe(); // using root recipe for widget below const ResponsiveGridLayout = WidthProvider(GridLayout); // canvas width now adjusts to window size const handleDragStart = () => { document.body.style.userSelect = "none"; }; // don't allow text highlighting when dragging const handleDragStop = () => { document.body.style.userSelect = ""; }; // allow text highlighting all other times let merged = []; console.log("widgetArray: ", widgetArray); console.log("layout: ", layout); if (widgetArray.length && layout.length) { const widgetMap = new Map(widgetArray.map(item => [item.i, item])); merged = layout.map(item => { return { ...item, ...widgetMap.get(item.i) }; }); }; return ( {merged.map((item) => { const Widget = item.widget; return ( ) })} ); }