Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #30 from zooniverse/middleware-create-store
Browse files Browse the repository at this point in the history
Add root store with middleware.
  • Loading branch information
rogerhutchings committed Feb 9, 2016
2 parents 08443ec + fb44bfe commit 6bf3601
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@ import 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, IndexRoute } from 'react-router';
import { createStore } from 'redux';
import { Provider } from 'react-redux';

import reducers from './reducers/reducers.js';
import { Provider } from 'react-redux';

import App from './components/App.jsx';
import Home from './components/Home.jsx';
import LoginHandler from './components/LoginHandler.jsx';

import MapExplorer from './components/MapExplorer.jsx';
import Teachers from './components/Teachers.jsx';
import TeachersDashboard from './components/TeachersDashboard.jsx';

import Styles from './styles/main.styl';

import configureStore from './store/configureStore';

const store = configureStore();

window.React = React;
let store = createStore(reducers);


ReactDOM.render(
<Provider store={store}>
Expand Down
17 changes: 17 additions & 0 deletions src/store/configureStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { createStore, applyMiddleware } from 'redux';
import thunkMiddleware from 'redux-thunk';
import rootReducer from '../reducers/reducers';
const createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore);

export default function configureStore(initialState) {
const store = createStoreWithMiddleware(rootReducer, initialState);

if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers/reducers', () => {
const nextRootReducer = require('../reducers/reducers');
store.replaceReducer(nextRootReducer);
});
}
return store;
}

0 comments on commit 6bf3601

Please sign in to comment.