aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-07-03 22:05:14 +0200
committerNoah Loomans <noahloomans@gmail.com>2018-07-03 22:05:14 +0200
commit4f7bd934ec97bb240239abc4ce8e18ef01546ece (patch)
treebb6804dc317075a7bbbc6c9fb0e3be1383683f33 /src
parentbb9ecd90442ef7827c5620dd9d354ee48716e4db (diff)
client: Move middleware creation to seperate file
Diffstat (limited to 'src')
-rw-r--r--src/client/react/index.js16
-rw-r--r--src/client/react/lib/reduxMiddleware.js11
2 files changed, 16 insertions, 11 deletions
diff --git a/src/client/react/index.js b/src/client/react/index.js
index f01a361..22afe3b 100644
--- a/src/client/react/index.js
+++ b/src/client/react/index.js
@@ -23,13 +23,12 @@ import 'whatwg-fetch';
import React from 'react';
import ReactDOM from 'react-dom';
-import { createStore, applyMiddleware, compose as reduxCompose } from 'redux';
-import thunk from 'redux-thunk';
+import { createStore, compose as reduxCompose } from 'redux';
import moment from 'moment';
import createHistory from 'history/createBrowserHistory';
-import makeGetHistory from './lib/getHistory';
+import makeReduxMiddleware from './lib/reduxMiddleware';
import reducer from './store/reducers';
import App from './App';
import './index.scss';
@@ -40,18 +39,13 @@ moment.locale('nl');
const history = createHistory();
+// Redux devtools extension
+// https://github.com/zalmoxisus/redux-devtools-extension
const compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || reduxCompose;
const store = createStore(
reducer,
- // Redux devtools extension
- // https://github.com/zalmoxisus/redux-devtools-extension
- compose(
- applyMiddleware(thunk.withExtraArgument({
- getHistory: makeGetHistory(history),
- moment,
- })),
- ),
+ compose(makeReduxMiddleware({ history })),
);
ReactDOM.render(
diff --git a/src/client/react/lib/reduxMiddleware.js b/src/client/react/lib/reduxMiddleware.js
new file mode 100644
index 0000000..c153022
--- /dev/null
+++ b/src/client/react/lib/reduxMiddleware.js
@@ -0,0 +1,11 @@
+import moment from 'moment';
+import { applyMiddleware } from 'redux';
+import thunk from 'redux-thunk';
+import makeGetHistory from './getHistory';
+
+export default function makeReduxMiddleware({ history }) {
+ return applyMiddleware(thunk.withExtraArgument({
+ getHistory: makeGetHistory(history),
+ moment,
+ }));
+}