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

Commit afd8c69

Browse files
sfentresstimdorr
authored andcommitted
Improve instructions for using with Immutable.js (#416)
1. It was easier for me to think of the reducer by first knowing where the state was expected to be. Writing it the other way around was confusing 2. Add that the action payload data must go into the `locationBeforeTransitions` property #415
1 parent 708b541 commit afd8c69

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ history.listen(location => analyticsService.track(location.pathname))
8181

8282
For other kinds of events in your system, you can use middleware on your Redux store like normal to watch any action that is dispatched to the store.
8383

84-
#### What if I use Immutable.js with my Redux store?
84+
#### What if I use Immutable.js or another wrapper with my Redux store?
8585

8686
When using a wrapper for your store's state, such as Immutable.js, you will need to change two things from the standard setup:
8787

88-
1. Provide your own reducer function that will receive actions of type `LOCATION_CHANGE` and return the payload merged into state.
89-
2. Pass a selector to access the payload state and convert it to a JS object via the `selectLocationState` option on `syncHistoryWithStore`.
88+
1. By default, the library expects to find the router state at `state.routing`. If your wrapper prevents accessing properties directly, or you want to put the routing state elsewhere, pass a selector to access the payload state and convert it to a JS object via the `selectLocationState` option on `syncHistoryWithStore`.
89+
2. Provide your own reducer function that will receive actions of type `LOCATION_CHANGE` and return the payload merged into the `locationBeforeTransitions` property of the routing state. For example, `state.set("routing", {locationBeforeTransitions: action.payload})`.
9090

9191
These two hooks will allow you to store the state that this library uses in whatever format or wrapper you would like.
9292

0 commit comments

Comments
 (0)