Skip to content

Commit

Permalink
feat: allow defining displayName on EuiFlexItem and EuiFlexGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
tkajtoch committed May 1, 2024
1 parent a26c214 commit 69865ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/components/flex/flex_group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import React, {
ElementType,
ForwardedRef,
forwardRef,
FunctionComponent,
PropsWithChildren,
Ref,
} from 'react';
Expand Down Expand Up @@ -121,14 +120,13 @@ const EuiFlexGroupInternal = <TComponent extends ComponentPropType>(

// Cast forwardRef return type to work with the generic TComponent type
// and not fallback to implicit any typing
export const EuiFlexGroup = forwardRef(EuiFlexGroupInternal) as <
TComponent extends ComponentPropType,
export const EuiFlexGroup = forwardRef(EuiFlexGroupInternal) as (<
TComponent extends ComponentPropType = 'div',
TComponentRef = ReturnType<typeof EuiFlexGroupInternal>
>(
props: EuiFlexGroupProps<TComponent> & {
ref?: Ref<TComponentRef>;
}
) => ReturnType<typeof EuiFlexGroupInternal>;
) => ReturnType<typeof EuiFlexGroupInternal>) & { displayName?: string };

// Cast is required here because of the cast above
(EuiFlexGroup as FunctionComponent).displayName = 'EuiFlexGroup';
EuiFlexGroup.displayName = 'EuiFlexGroup';
8 changes: 3 additions & 5 deletions src/components/flex/flex_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import React, {
ComponentType,
ForwardedRef,
forwardRef,
FunctionComponent,
Ref,
} from 'react';
import classNames from 'classnames';
Expand Down Expand Up @@ -110,14 +109,13 @@ const EuiFlexItemInternal = <TComponent extends ComponentPropType>(

// Cast forwardRef return type to work with the generic TComponent type
// and not fallback to implicit any typing
export const EuiFlexItem = forwardRef(EuiFlexItemInternal) as <
export const EuiFlexItem = forwardRef(EuiFlexItemInternal) as (<
TComponent extends ComponentPropType,
TComponentRef = ReturnType<typeof EuiFlexItemInternal>
>(
props: EuiFlexItemProps<TComponent> & {
ref?: Ref<TComponentRef>;
}
) => ReturnType<typeof EuiFlexItemInternal>;
) => ReturnType<typeof EuiFlexItemInternal>) & { displayName?: string };

// Cast is required here because of the cast above
(EuiFlexItem as FunctionComponent).displayName = 'EuiFlexItem';
EuiFlexItem.displayName = 'EuiFlexItem';

0 comments on commit 69865ae

Please sign in to comment.