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

Commit

Permalink
Improve instructions for using with Immutable.js (#416)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sfentress authored and timdorr committed Jun 28, 2016
1 parent 708b541 commit afd8c69
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ history.listen(location => analyticsService.track(location.pathname))

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.

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

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

1. Provide your own reducer function that will receive actions of type `LOCATION_CHANGE` and return the payload merged into state.
2. Pass a selector to access the payload state and convert it to a JS object via the `selectLocationState` option on `syncHistoryWithStore`.
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`.
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})`.

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

Expand Down

0 comments on commit afd8c69

Please sign in to comment.