diff options
Diffstat (limited to 'frontend/src/reducers.js')
-rw-r--r-- | frontend/src/reducers.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/frontend/src/reducers.js b/frontend/src/reducers.js index 9befff13..097f9243 100644 --- a/frontend/src/reducers.js +++ b/frontend/src/reducers.js @@ -1,5 +1,20 @@ -import { combineReducers } from 'redux' -import { routerReducer } from 'react-router-redux' +import { combineReducers } from 'redux-immutable' + +// react-router-redux immutable reducer +import { fromJS } from 'immutable' +import { LOCATION_CHANGE } from 'react-router-redux' + +const initialState = fromJS({ + locationBeforeTransitions: null +}) + +const routerImmutableReducer = (state = initialState, action) => { + if (action.type === LOCATION_CHANGE) { + return state.set('locationBeforeTransitions', action.payload) + } + + return state +} import gamesReducer from './redux/games' import playersReducer from './redux/players' @@ -7,7 +22,7 @@ import playersReducer from './redux/players' export default function createReducer() { return combineReducers({ games: gamesReducer, - routing: routerReducer, + routing: routerImmutableReducer, players: playersReducer, }) } |