Skip to content

Commit beea2ef

Browse files
committed
Make use of overrideComponentTypeChecker to allow hot reloading without issues
1 parent 24c9035 commit beea2ef

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/app/client.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import ReactDOM from 'react-dom';
33
import App from './App';
44
import { AppContainer } from 'react-hot-loader';
5+
import { overrideComponentTypeChecker } from 'react-toolbox';
56

67
const rootEl = document.getElementById('app');
78

@@ -14,8 +15,16 @@ const render = () => {
1415
);
1516
};
1617

17-
if (module.hot) {
18-
module.hot.accept('./App', render);
18+
if (process.env.NODE_ENV !== 'production') {
19+
overrideComponentTypeChecker((classType, reactElement) => (
20+
reactElement && (
21+
reactElement.type === classType ||
22+
reactElement.type.name === classType.displayName
23+
)
24+
));
25+
if (module.hot) {
26+
module.hot.accept('./App', render);
27+
}
1928
}
2029

2130
render();

0 commit comments

Comments
 (0)