Skip to content

Commit 608805a

Browse files
committed
fix: update root endpoint, fixes #1226, #1240
1 parent 0c79474 commit 608805a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

root.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@ if (module.hot) {
22
var hot = require('./index').hot;
33
var cache = require.cache;
44

5-
if (!module.parents || !module.parents[0]) {
5+
if (!module.parents || module.parents.length === 0) {
66
throw new Error(
77
'React-Hot-Loader: `react-hot-loader/root` is not supported on your system. ' +
88
'Please use `import {hot} from "react-hot-loader"` instead',
99
);
1010
}
1111
// access parent
1212
var parent = cache[module.parents[0]];
13-
// remove itself from a cache
13+
if (!parent) {
14+
throw new Error(
15+
'React-Hot-Loader: `react-hot-loader/root` is not supported on your system. ' +
16+
'Please use `import {hot} from "react-hot-loader"` instead',
17+
);
18+
}
19+
// remove self from a cache
1420
delete cache[module.id];
1521
// setup hot for caller
16-
17-
exports.hot = hot(Object.assign({ id: parent.i }, parent));
22+
exports.hot = hot(parent);
1823
} else {
1924
// prod mode
2025
exports.hot = function(a) {

0 commit comments

Comments
 (0)