import * as React from 'react'; export const getComponentName = (component: unknown) => { if (!React.isValidElement(component)) return undefined; try { const type = component.type as unknown as { displayName: string; name: string; }; return type.displayName || type.name || undefined; } catch (e) { console.error(e); } return undefined; };