Add route data to reducer action #205
Description
My route that I am using looks like this:
<Route path="/messages/:id" component={Message} />
In my Message
component I have access to this.props.params.id
.
In my reducer my action
looks like this:
location: {
action: "POP"
hash: "#/messages/2?_k=xcl5yg"
key: "u1jk2m"
pathname: "/"
search: ""
state: null
},
type: "@@router/UPDATE_LOCATION"
So a couple issues I see here.
First, using this relies on my reducer knowing first hand whether the router is using hash
or pushState
. I shouldn't have to change my reducers if I change how my router is configured.
Second, there is a params object given to my component via the router but not present in the action.
To solve these I think there needs to be an extra route
object on the action so it looks like so:
location: {
action: "POP"
hash: "#/messages/2?_k=xcl5yg"
key: "u1jk2m"
pathname: "/"
search: ""
state: null
},
route: {
path: "/messages/2",
params: {
id: 2
}
},
type: "@@router/UPDATE_LOCATION"
If I am just completely off base on this or using this library wrong then please point me in the right direction. Also I would be more than willing to help out with this, I have experience hacking on routers