From 45245187e2f7b360e1f22a4ce2ec1fdccbb885bf Mon Sep 17 00:00:00 2001 From: benox3 Date: Mon, 6 May 2019 13:55:37 -0400 Subject: [PATCH] refactor: add a static on the function for better id of comp type --- src/DataScroller.tsx | 10 +++------- src/components/Column/Column.tsx | 3 +++ src/components/Group/Group.tsx | 3 +++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/DataScroller.tsx b/src/DataScroller.tsx index 323b8a21..5f6bd880 100644 --- a/src/DataScroller.tsx +++ b/src/DataScroller.tsx @@ -23,10 +23,8 @@ const getColumns = (node: React.ReactNode) => { if ( column.props && - (column.type === Column || - // This is necessary for HMR - // @ts-ignore - column.type.displayName === 'Column') + // @ts-ignore + column.type.__Column__ ) { return [...acc, column.props]; } @@ -67,10 +65,8 @@ const getColumnsAndGroups = ( } if ( - elementChild.type === Group || - // This is necessary for HMR // @ts-ignore - elementChild.type.displayName === 'Group' + elementChild.type.__Group__ ) { return { ...acc, diff --git a/src/components/Column/Column.tsx b/src/components/Column/Column.tsx index 4ed979cd..cd36c81b 100644 --- a/src/components/Column/Column.tsx +++ b/src/components/Column/Column.tsx @@ -13,3 +13,6 @@ export type Props = { export default function Column(props: Props) { return null; } + +// Used for identifying the component type when iterating through children +Column.__Column__ = true; diff --git a/src/components/Group/Group.tsx b/src/components/Group/Group.tsx index f46eecc4..14981a83 100644 --- a/src/components/Group/Group.tsx +++ b/src/components/Group/Group.tsx @@ -10,3 +10,6 @@ export type Props = { export default function Group({ children, headerRenderer, groupData }: Props) { return null; } + +// Used for identifying the component type when iterating through children +Group.__Group__ = true;