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

Commit 0d20158

Browse files
committed
Merge pull request #241 from robertfall/master
Update README with info on react-redux route params
2 parents 5f9b7ec + 81f075f commit 0d20158

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ function update(state, action) {
103103
}
104104
}
105105
```
106+
**But how do I access router props in a Container component?**
107+
108+
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:
109+
110+
```js
111+
function mapStateToProps(state, ownProps) {
112+
return {
113+
id: ownProps.params.id,
114+
filter: ownProps.location.query.filter
115+
};
116+
}
117+
```
118+
106119

107120
### Examples
108121

0 commit comments

Comments
 (0)