2015-07-14 22:46:44 +03:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import TodoApp from './TodoApp';
|
2015-07-15 00:25:02 +03:00
|
|
|
import { createStore, combineReducers, compose } from 'redux';
|
|
|
|
import { devTools, persistState } from 'redux-devtools';
|
|
|
|
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react';
|
2015-07-14 22:46:44 +03:00
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import * as reducers from '../reducers';
|
|
|
|
|
2015-07-15 00:25:02 +03:00
|
|
|
const finalCreateStore = compose(
|
|
|
|
devTools(),
|
2015-09-01 04:40:45 +03:00
|
|
|
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
|
|
|
|
)(createStore);
|
2015-07-15 00:25:02 +03:00
|
|
|
|
2015-07-14 22:46:44 +03:00
|
|
|
const reducer = combineReducers(reducers);
|
2015-07-15 00:25:02 +03:00
|
|
|
const store = finalCreateStore(reducer);
|
2015-07-14 22:46:44 +03:00
|
|
|
|
2015-09-01 04:40:45 +03:00
|
|
|
if (module.hot) {
|
|
|
|
module.hot.accept('../reducers', () =>
|
|
|
|
store.replaceReducer(combineReducers(require('../reducers')))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-07-14 22:46:44 +03:00
|
|
|
export default class App extends Component {
|
|
|
|
render() {
|
|
|
|
return (
|
2015-07-15 00:25:02 +03:00
|
|
|
<div>
|
|
|
|
<Provider store={store}>
|
|
|
|
{() => <TodoApp /> }
|
|
|
|
</Provider>
|
|
|
|
<DebugPanel top right bottom>
|
|
|
|
<DevTools store={store}
|
|
|
|
monitor={LogMonitor} />
|
|
|
|
</DebugPanel>
|
|
|
|
</div>
|
2015-07-14 22:46:44 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|