From bbc6769ca0399ef4180ce6fcf6c9a3e179b63f8d Mon Sep 17 00:00:00 2001 From: acd02 Date: Fri, 29 Mar 2024 17:05:40 +0100 Subject: [PATCH] fix(dialog): use optional chaining operator to safely access node id, preventing runtime errors Use optional chaining operator to safely access node id, preventing runtime errors when node.type is not present --- packages/components/dialog/src/DialogContext.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/dialog/src/DialogContext.tsx b/packages/components/dialog/src/DialogContext.tsx index 51fe43887..0896164e1 100644 --- a/packages/components/dialog/src/DialogContext.tsx +++ b/packages/components/dialog/src/DialogContext.tsx @@ -21,7 +21,7 @@ export const DialogProvider = ({ children: childrenProp }: { children: ReactNode const [hasCloseButton, setHasCloseButton] = useState(false) const closeButton = deepFind(childrenProp, node => { - const reactElementId = ((node as ReactElement)?.type as { id?: string }).id + const reactElementId = ((node as ReactElement)?.type as { id?: string })?.id return reactElementId === 'CloseButton' })