Skip to content

Instantly share code, notes, and snippets.

@merk
Created August 5, 2015 03:21
Show Gist options
  • Save merk/77246c12907ec979b126 to your computer and use it in GitHub Desktop.
Save merk/77246c12907ec979b126 to your computer and use it in GitHub Desktop.
import React from 'react';
import { Provider } from 'react-redux';
import { Router, Route } from 'react-router';
import { reduxRouteComponent } from 'redux-react-router';
import { checkAuthentication } from '../actions/AuthActions.js';
import Root from './Layout/Root';
import Dashboard from './Dashboard';
import 'jquery';
import 'bootstrap';
export default class App extends React.Component {
static propTypes = {
history: React.PropTypes.object.isRequired,
store: React.PropTypes.object.isRequired,
};
static getRoutes(history, store) {
return <Router history={history}>
<Route component={reduxRouteComponent(store)}>
<Route component={Root}>
<Route path="/" component={Dashboard} />
</Route>
</Route>
</Router>;
};
render() {
const { history, store } = this.props;
return <Provider store={store}>
{() => App.getRoutes(history, store)}
</Provider>;
}
}
import 'babel-core/polyfill';
import React from 'react';
import BrowserHistory from 'react-router/lib/BrowserHistory';
import App from './components/App';
import store from './store';
const appEl = document.getElementById('app');
React.render(<App history={BrowserHistory} store={store} />, appEl);
import { applyMiddleware, combineReducers, createStore } from 'redux';
import { routerStateReducer } from 'redux-react-router';
import logMiddleware from './middleware/log.js';
import promiseMiddleware from './middleware/promise.js';
import thunkMiddleware from 'redux-thunk';
import * as reducers from './reducers';
const middlewares = [thunkMiddleware, promiseMiddleware, logMiddleware];
const createStoreWithMiddleware = applyMiddleware(...middlewares)(createStore);
const reducer = combineReducers({
router: routerStateReducer,
...reducers
});
export default createStoreWithMiddleware(reducer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment