From 171301a48cad408d721884f19c5a6263cd32074c Mon Sep 17 00:00:00 2001 From: Simone Duca Date: Tue, 9 Feb 2016 11:46:28 +0000 Subject: [PATCH 1/3] Add root store with middleware. --- src/Index.jsx | 11 +++++++---- src/store/configureStore.js | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/store/configureStore.js diff --git a/src/Index.jsx b/src/Index.jsx index e4f83e6..9622e65 100644 --- a/src/Index.jsx +++ b/src/Index.jsx @@ -3,20 +3,23 @@ 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 { Provider } from 'react-redux'; import App from './components/App.jsx'; -import reducers from './reducers/reducers.js'; +//import reducers from './reducers/reducers.js'; import Home from './components/Home.jsx'; import Teachers from './components/Teachers.jsx'; import TeachersDashboard from './components/TeachersDashboard.jsx' import MapExplorer from './components/MapExplorer.jsx'; import Styles from './styles/main.styl'; +import configureStore from './store/configureStore'; + +const store = configureStore(); + window.React = React; -let store = createStore(reducers) + ReactDOM.render( diff --git a/src/store/configureStore.js b/src/store/configureStore.js new file mode 100644 index 0000000..2d2a5a3 --- /dev/null +++ b/src/store/configureStore.js @@ -0,0 +1,18 @@ +import { createStore, applyMiddleware } from 'redux'; +import thunkMiddleware from 'redux-thunk'; +//import rootReducer from '../reducers'; +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 +} From 114f3ef0040743331001f5cf2118fed9f13ddac3 Mon Sep 17 00:00:00 2001 From: Simone Duca Date: Tue, 9 Feb 2016 12:13:40 +0000 Subject: [PATCH 2/3] linting/styling --- src/Index.jsx | 3 +-- src/store/configureStore.js | 13 ++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Index.jsx b/src/Index.jsx index 9622e65..8d84a85 100644 --- a/src/Index.jsx +++ b/src/Index.jsx @@ -7,10 +7,9 @@ import { Provider } from 'react-redux'; import App from './components/App.jsx'; -//import reducers from './reducers/reducers.js'; import Home from './components/Home.jsx'; import Teachers from './components/Teachers.jsx'; -import TeachersDashboard from './components/TeachersDashboard.jsx' +import TeachersDashboard from './components/TeachersDashboard.jsx'; import MapExplorer from './components/MapExplorer.jsx'; import Styles from './styles/main.styl'; diff --git a/src/store/configureStore.js b/src/store/configureStore.js index 2d2a5a3..1df8c2e 100644 --- a/src/store/configureStore.js +++ b/src/store/configureStore.js @@ -1,18 +1,17 @@ import { createStore, applyMiddleware } from 'redux'; import thunkMiddleware from 'redux-thunk'; -//import rootReducer from '../reducers'; import rootReducer from '../reducers/reducers'; -const createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore) +const createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore); export default function configureStore(initialState) { - const store = createStoreWithMiddleware(rootReducer, 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) - }) + const nextRootReducer = require('../reducers/reducers'); + store.replaceReducer(nextRootReducer); + }); } - return store + return store; } From fb44bfe6d8f08387f3b47c7fffc3adde296af2da Mon Sep 17 00:00:00 2001 From: Simone Duca Date: Tue, 9 Feb 2016 12:25:42 +0000 Subject: [PATCH 3/3] final conflicts --- src/Index.jsx | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/Index.jsx b/src/Index.jsx index 186d2e8..24251cf 100644 --- a/src/Index.jsx +++ b/src/Index.jsx @@ -3,24 +3,13 @@ import 'babel-polyfill'; import React from 'react'; import ReactDOM from 'react-dom'; import { Router, Route, IndexRoute } from 'react-router'; -<<<<<<< HEAD -import { Provider } from 'react-redux'; - -import App from './components/App.jsx'; -import Home from './components/Home.jsx'; -import Teachers from './components/Teachers.jsx'; -import TeachersDashboard from './components/TeachersDashboard.jsx'; -======= -import { createStore } from 'redux'; import { Provider } from 'react-redux'; -import reducers from './reducers/reducers.js'; - import App from './components/App.jsx'; import Home from './components/Home.jsx'; import LoginHandler from './components/LoginHandler.jsx'; ->>>>>>> master + import MapExplorer from './components/MapExplorer.jsx'; import Teachers from './components/Teachers.jsx'; import TeachersDashboard from './components/TeachersDashboard.jsx'; @@ -32,10 +21,7 @@ import configureStore from './store/configureStore'; const store = configureStore(); window.React = React; -<<<<<<< HEAD -======= -let store = createStore(reducers); ->>>>>>> master + ReactDOM.render(