Skip to content

Commit 431abb1

Browse files
tomchentwjavivelasco
authored andcommitted
Add workaround to is-component-of-type for react-hot-loader@^3 (#1569)
1 parent 2124c8c commit 431abb1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

components/utils/is-component-of-type.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
let customChecker;
24

35
/**
@@ -16,6 +18,10 @@ export function overrideComponentTypeChecker(providedChecker) {
1618
* @param reactElement {ReactElement} - any React Element (not a real DOM node)
1719
*/
1820
export function defaultChecker(classType, reactElement) {
21+
if (process.env.NODE_ENV !== 'production') {
22+
// https://github.com/gaearon/react-hot-loader/blob/v3.0.0-beta.7/docs/Known%20Limitations.md#checking-element-types
23+
classType = React.createElement(classType).type;// eslint-disable-line no-param-reassign
24+
}
1925
return reactElement && reactElement.type === classType;
2026
}
2127

0 commit comments

Comments
 (0)