static-cms/src/index.js

39 lines
886 B
JavaScript
Raw Normal View History

2016-02-25 00:45:56 -08:00
import React from 'react';
import { render } from 'react-dom';
2016-09-15 18:53:24 +02:00
import { AppContainer } from 'react-hot-loader';
import Root from './root';
2016-09-11 23:08:18 +02:00
import registry from './lib/registry';
2016-02-25 00:45:56 -08:00
import 'file?name=index.html!../example/index.html';
2016-09-15 18:53:24 +02:00
import 'react-toolbox/lib/commons.scss';
2016-07-08 07:12:52 -03:00
import './index.css';
2016-02-25 00:45:56 -08:00
2016-09-13 17:08:26 +02:00
// Create mount element dynamically
2016-02-25 00:45:56 -08:00
const el = document.createElement('div');
2016-07-05 15:48:18 -03:00
el.id = 'root';
2016-02-25 00:45:56 -08:00
document.body.appendChild(el);
render((
2016-09-13 17:08:26 +02:00
<AppContainer>
<Root />
</AppContainer>
2016-02-25 00:45:56 -08:00
), el);
2016-09-13 17:08:26 +02:00
if (module.hot) {
module.hot.accept('./root', () => {
const NextRoot = require('./root').default;
render((
<AppContainer>
<NextRoot />
</AppContainer>
), el);
});
}
2016-09-11 23:08:18 +02:00
window.CMS = {};
console.log('reg: ', registry);
for (const method in registry) {
window.CMS[method] = registry[method];
}
2016-09-12 15:27:45 +02:00
window.createClass = React.createClass;
window.h = React.createElement;