From aaf0effcbbb1e8f28e6878fc678d94b333b2d09d Mon Sep 17 00:00:00 2001 From: Dhravya Shah Date: Thu, 1 Sep 2022 19:48:21 +0530 Subject: [PATCH] Fixed `TypeError: Cannot read properties of undefined (reading 'website_id')` --- components/pages/DashboardEdit.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/pages/DashboardEdit.js b/components/pages/DashboardEdit.js index d06f32f9..4b515f25 100644 --- a/components/pages/DashboardEdit.js +++ b/components/pages/DashboardEdit.js @@ -23,7 +23,6 @@ export default function DashboardEdit({ websites }) { const ordered = useMemo(() => sortArrayByMap(websites, order, 'website_id'), [websites, order]); - console.log({ order, ordered }); function handleWebsiteDrag({ destination, source }) { if (!destination || destination.index === source.index) return; @@ -32,7 +31,7 @@ export default function DashboardEdit({ websites }) { const [removed] = orderedWebsites.splice(source.index, 1); orderedWebsites.splice(destination.index, 0, removed); - setOrder(orderedWebsites.map(({ website_id }) => website_id)); + setOrder(orderedWebsites.map((website) => website?.website_id || 0)); } function handleSave() {