Skip to content
This repository was archived by the owner on Oct 26, 2018. It is now read-only.

Commit 22db2bb

Browse files
committed
use getLocationState instead of getRouterState as mentioned in #140
1 parent 5f1c531 commit 22db2bb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ _Have an example to add? Send us a PR!_
126126

127127
Call this to create a middleware that can be applied with Redux's `applyMiddleware` to allow actions to call history methods. The middleware will look for route actions created by `push`, `replace`, etc. and applies them to the history.
128128

129-
#### `ReduxMiddleware.listenForReplays(store: ReduxStore, selectRouterState?: function)`
129+
#### `ReduxMiddleware.listenForReplays(store: ReduxStore, selectLocationState?: function)`
130130

131131
By default, the syncing logic will not respond to replaying of actions, which means it won't work with projects like redux-devtools. Call this function on the middleware object returned from `syncHistory` and give it the store to listen to, and it will properly work with action replays. Obviously, you would do that after you have created the store and everything else has been set up.
132132

133-
Supply an optional function `selectRouterState` to customize where to find the router state on your app state. It defaults to `state => state.routing`, so you would install the reducer under the name "routing". Feel free to change this to whatever you like.
133+
Supply an optional function `selectLocationState` to customize where to find the location state on your app state. It defaults to `state => state.routing.location`, so you would install the reducer under the name "routing". Feel free to change this to whatever you like.
134134

135135
#### `ReduxMiddleware.unsubscribe()`
136136

src/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export const TRANSITION = '@@router/TRANSITION'
44
export const UPDATE_LOCATION = '@@router/UPDATE_LOCATION'
55

6-
const SELECT_STATE = state => state.routing
6+
const SELECT_LOCATION = state => state.routing.location
77

88
function transition(method) {
99
return arg => ({
@@ -71,12 +71,12 @@ export function syncHistory(history) {
7171
}
7272

7373
middleware.listenForReplays =
74-
(store, selectRouterState = SELECT_STATE) => {
75-
const getRouterState = () => selectRouterState(store.getState())
76-
const { location: initialLocation } = getRouterState()
74+
(store, selectLocationState = SELECT_LOCATION) => {
75+
const getLocationState = () => selectLocationState(store.getState())
76+
const initialLocation = getLocationState()
7777

7878
unsubscribeStore = store.subscribe(() => {
79-
const { location } = getRouterState()
79+
const location = getLocationState()
8080

8181
// If we're resetting to the beginning, use the saved initial value. We
8282
// need to dispatch a new action at this point to populate the store

0 commit comments

Comments
 (0)