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 37561a1 commit 7b8b65d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/CheckboxGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
import React, { cloneElement, PureComponent } from 'react';
import Checkbox from './Checkbox';

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

class CheckboxGroup extends PureComponent {
static propTypes = {
disabled: PropTypes.bool,
Expand Down Expand Up @@ -58,12 +60,12 @@ class CheckboxGroup extends PureComponent {
return child;
}

if (child.type === CheckboxGroup) {
if (child.type === getComponentType(CheckboxGroup)) {
// No nested checkbox groups
return child;
}

if (child.type === Checkbox) {
if (child.type === getComponentType(Checkbox)) {
return cloneElement(child, {
checked: this.state.value.indexOf(child.props.value) >= 0,
disabled: this.props.disabled || child.props.disabled,
Expand Down

0 comments on commit 7b8b65d

Please sign in to comment.