redux-devtools/examples/counter/containers/App.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-07-14 22:46:44 +03:00
import React, { Component } from 'react';
import CounterApp from './CounterApp';
2015-07-15 00:11:55 +03:00
import { createStore, applyMiddleware, 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 thunk from 'redux-thunk';
import { Provider } from 'react-redux';
import * as reducers from '../reducers';
2015-07-15 00:11:55 +03:00
const finalCreateStore = compose(
applyMiddleware(thunk),
devTools(),
2015-09-01 04:40:45 +03:00
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
)(createStore);
2015-07-15 00:11:55 +03:00
2015-07-14 22:46:44 +03:00
const reducer = combineReducers(reducers);
2015-07-15 00:11:55 +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:11:55 +03:00
<div>
<Provider store={store}>
{() => <CounterApp />}
</Provider>
<DebugPanel top right bottom>
<DevTools store={store}
2015-09-03 16:14:21 +03:00
monitor={LogMonitor}
visibleOnLoad={true} />
2015-07-15 00:11:55 +03:00
</DebugPanel>
</div>
2015-07-14 22:46:44 +03:00
);
}
}