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

Add route data to reducer action #205

Closed
@jisaacks

Description

@jisaacks

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions