Skip to content

Commit aa937b6

Browse files
committed
Address an issue where checking element type for imported components is not possible with projects using react-hot-loader
1 parent 6750fe8 commit aa937b6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/RadioGroup.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import React, { cloneElement, PureComponent } from 'react';
33
import PropTypes from 'prop-types';
44
import RadioButton from './RadioButton';
55

6+
const getComponentType = (Component) => (Component ? (<Component />).type : undefined);
7+
68
class RadioGroup extends PureComponent {
79
static propTypes = {
810
disabled: PropTypes.bool,
@@ -50,12 +52,12 @@ class RadioGroup extends PureComponent {
5052
return child;
5153
}
5254

53-
if (child.type === RadioGroup) {
55+
if (child.type === getComponentType(RadioGroup)) {
5456
// No nested radio groups
5557
return child;
5658
}
5759

58-
if (child.type === RadioButton) {
60+
if (child.type === getComponentType(RadioButton)) {
5961
return cloneElement(child, {
6062
checked: (this.state.value !== undefined) && (this.state.value === child.props.value),
6163
disabled: this.props.disabled || child.props.disabled,

0 commit comments

Comments
 (0)