Skip to content

Commit 5d453ce

Browse files
Copilotmikebarkmin
andcommitted
Fix null reference error in preview mode
- Add null check for node in useMemo before accessing node.data - Update early return condition to check both open and node - Fixes "can't access property 'data', o is null" error Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
1 parent 0ff29e7 commit 5d453ce

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/learningmap/src/Drawer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ export function Drawer({ open, onClose, onUpdate, node, nodes, onNodeClick, lang
6262

6363
// Parse markdown description and sanitize HTML
6464
const descriptionHtml = useMemo(() => {
65-
if (!node.data?.description) return '';
65+
if (!node || !node.data?.description) return '';
6666
const rawHtml = marked.parse(node.data.description, { async: false });
6767
return DOMPurify.sanitize(rawHtml);
68-
}, [node.data?.description]);
68+
}, [node, node?.data?.description]);
6969

70-
if (!open) return null;
70+
if (!open || !node) return null;
7171

7272
const locked = node.data?.state === 'locked' || false;
7373
const unlocked = node.data?.state === 'unlocked' || false;

0 commit comments

Comments
 (0)