forked from gaearon/react-hot-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRootInstanceProvider.js
41 lines (32 loc) · 1.16 KB
/
RootInstanceProvider.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
var getRootInstancesFromReactMount = require('./getRootInstancesFromReactMount');
var injectedProvider = null,
didWarn = false;
function warnOnce() {
if (!didWarn) {
console.warn(
'It appears that React Hot Loader isn\'t configured correctly. ' +
'If you\'re using NPM, make sure your dependencies don\'t drag duplicate React distributions into their node_modules and that require("react") corresponds to the React instance you render your app with.',
'If you\'re using a precompiled version of React, see https://github.com/gaearon/react-hot-loader/tree/master/docs#usage-with-external-react for integration instructions.'
);
}
didWarn = true;
}
var RootInstanceProvider = {
injection: {
injectProvider: function (provider) {
injectedProvider = provider;
}
},
getRootInstances: function (ReactMount) {
if (injectedProvider) {
return injectedProvider.getRootInstances();
}
var instances = ReactMount && getRootInstancesFromReactMount(ReactMount) || [];
if (!Object.keys(instances).length) {
warnOnce();
}
return instances;
}
};
module.exports = RootInstanceProvider;