Skip to content

Commit 0db894c

Browse files
committed
Fail hard on missing reducer
1 parent e271f55 commit 0db894c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

examples/real-world/syncHistoryWithStore.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ export function syncHistoryWithStore(history, store, {
2222
selectLocationState = state => state.routing,
2323
adjustUrlOnReplay = false
2424
} = {}) {
25+
// Fail early if the reducer is not mounted
26+
if (typeof selectLocationState(store.getState()) === 'undefined') {
27+
throw new Error(
28+
'Expected the routing state to be available either as `state.routing` ' +
29+
'or as the custom expression you can specify as `selectLocationState` ' +
30+
'named argument in the `syncHistoryWithStore()` options. Did you ' +
31+
'forget to put the `reducer` exported from `syncHistoryWithStore` into ' +
32+
'your `combineReducers()` call?'
33+
)
34+
}
35+
2536
let initialLocation
2637
let currentLocation
2738
let isTimeTraveling

0 commit comments

Comments
 (0)