From 6496d1b1dcc73dfd4f3f5e689439f32f92628632 Mon Sep 17 00:00:00 2001 From: Cheton Wu Date: Fri, 10 Aug 2018 17:04:23 +0800 Subject: [PATCH] Address an issue where checking element type for imported components is not possible with projects using react-hot-loader --- src/TabContent.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TabContent.jsx b/src/TabContent.jsx index 3cfea3a..8c94452 100644 --- a/src/TabContent.jsx +++ b/src/TabContent.jsx @@ -4,6 +4,8 @@ import React, { cloneElement, PureComponent } from 'react'; import TabPane from './TabPane'; import styles from './index.styl'; +const getComponentType = (Component) => (Component ? ().type : undefined); + class TabContent extends PureComponent { static propTypes = { activeKey: PropTypes.any @@ -18,7 +20,7 @@ class TabContent extends PureComponent { className={cx(className, styles.tabContent)} > {React.Children.map(children, child => { - if (React.isValidElement(child) && child.type === TabPane) { + if (React.isValidElement(child) && child.type === getComponentType(TabPane)) { const active = (child.props.eventKey === activeKey); return cloneElement(child, {