Skip to content

Commit

Permalink
Address an issue where checking element type for imported components …
Browse files Browse the repository at this point in the history
…is not possible with projects using react-hot-loader
  • Loading branch information
cheton committed Aug 10, 2018
1 parent 72d2852 commit 6496d1b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/TabContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import React, { cloneElement, PureComponent } from 'react';
import TabPane from './TabPane';
import styles from './index.styl';

const getComponentType = (Component) => (Component ? (<Component />).type : undefined);

class TabContent extends PureComponent {
static propTypes = {
activeKey: PropTypes.any
Expand All @@ -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, {
Expand Down

0 comments on commit 6496d1b

Please sign in to comment.