j-gallery
Version:
a picture layout library
41 lines (32 loc) • 1.18 kB
JavaScript
;
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;