Skip to content

Commit 57a26ca

Browse files
author
Jannik Weise
committed
🐛 Fix check for display name to check if type is string before
Prevents potential errors by ensuring that `el.type` is not undefined before accessing its properties, specifically when checking for a click handler in the accordion component. Adds a check to confirm that `el.type` is not a string and exists before attempting to access `el.type.displayName`. This prevents unexpected behavior when `el.type` is not an object with a `displayName` property.
1 parent 8d84c40 commit 57a26ca

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/core/src/utils/accordion.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@ export const getElementClickEvent = (element: ReactNode) => {
5252
const checkForClickHandler = (el: ReactNode) => {
5353
if (!isValidElement(el)) return;
5454

55-
// @ts-expect-error: Difficult to type
56-
if ('displayName' in el.type && el.type.displayName === 'Checkbox') {
55+
console.debug('el', el);
56+
57+
if (
58+
typeof el.type !== 'string' &&
59+
'displayName' in el.type &&
60+
el.type.displayName === 'Checkbox'
61+
) {
5762
hasClickHandler = true;
5863

5964
return;

0 commit comments

Comments
 (0)