-
-
Save anonymous/5c9e10fd3962ca68de18894ea19625e0 to your computer and use it in GitHub Desktop.
redux dev tools with applyMiddleware using compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, PropTypes } from 'react' | |
import { render } from 'react-dom' | |
import { applyMiddleware, combineReducers, createStore, compose } from 'redux' | |
import { Provider, connect } from 'react-redux' | |
import thunk from 'redux-thunk' | |
import { Router, Route, Link, IndexRoute, browserHistory } from 'react-router' | |
let enhancer = applyMiddleware(thunk); | |
const hasReduxDevTools = !!window.devToolsExtension; | |
if (hasReduxDevTools) { | |
enhancer = compose(enhancer, window.devToolsExtension()); | |
} | |
const rootReducer = (state = 0, action) => state; | |
const store = createStore(rootReducer, enhancer); | |
const Layout = (props) => | |
<div id="app">{props.children}</div> | |
const App = () => | |
<h1>Hello World!</h1> | |
const Main = () => | |
<Provider store={store}> | |
<Router history={browserHistory}> | |
<Route path="/" component={Layout}> | |
<IndexRoute component={App} /> | |
</Route> | |
</Router> | |
</Provider> | |
render(<Main />, document.getElementById('app')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment