Enabled HMR

This commit is contained in:
Andrey Okonetchnikov
2016-09-13 17:08:26 +02:00
parent 3deec4060f
commit 3f4bc929e9
4 changed files with 67 additions and 24 deletions

View File

@ -1,31 +1,34 @@
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { Router } from 'react-router';
import { AppContainer } from 'react-hot-loader'
import Root from './root'
import registry from './lib/registry';
import configureStore from './store/configureStore';
import routes from './routing/routes';
import history, { syncHistory } from './routing/history';
import 'file?name=index.html!../example/index.html';
import './index.css';
const store = configureStore();
// Create an enhanced history that syncs navigation events with the store
syncHistory(store);
// Create mount element dynamically
const el = document.createElement('div');
el.id = 'root';
document.body.appendChild(el);
render((
<Provider store={store}>
<Router history={history}>
{routes}
</Router>
</Provider>
<AppContainer>
<Root />
</AppContainer>
), el);
if (module.hot) {
module.hot.accept('./root', () => {
const NextRoot = require('./root').default;
console.log(NextRoot);
render((
<AppContainer>
<NextRoot />
</AppContainer>
), el);
});
}
window.CMS = {};
console.log('reg: ', registry);
for (const method in registry) {