Skip to content

Commit

Permalink
fix(dialog): use optional chaining operator to safely access node id,…
Browse files Browse the repository at this point in the history
… preventing runtime errors

Use optional chaining operator to safely access node id, preventing runtime errors when node.type is
not present
  • Loading branch information
acd02 committed Mar 29, 2024
1 parent ed38f99 commit bbc6769
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/components/dialog/src/DialogContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
})
Expand Down

0 comments on commit bbc6769

Please sign in to comment.