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

Commit

Permalink
Merge pull request #241 from robertfall/master
Browse files Browse the repository at this point in the history
Update README with info on react-redux route params
  • Loading branch information
timdorr committed Jan 26, 2016
2 parents 5f9b7ec + 81f075f commit 0d20158
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ function update(state, action) {
}
}
```
**But how do I access router props in a Container component?**

react-router [injects route information via a child component's props](https://github.com/rackt/react-router/blob/latest/docs/Introduction.md#getting-url-parameters). This makes accessing them from a simple component easy. When using a react-redux Container to connect simple components to the store state and dispatch you can access these injected route information from the [2nd argument of `mapStateToProps`](https://github.com/rackt/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options) as follows:

```js
function mapStateToProps(state, ownProps) {
return {
id: ownProps.params.id,
filter: ownProps.location.query.filter
};
}
```


### Examples

Expand Down

0 comments on commit 0d20158

Please sign in to comment.