简体   繁体   中英

How to get this.props.params populated in react-router v1.0.0?

When I try accessing this.props.params , it is undefined. this.context.router is {} .

I played with the different variations of adding contextTypes to my component:

contextTypes: {
      router: React.PropTypes.func.isRequired
}

but had no luck.

My main goal is to pass the current react-router url to the server.

As shown here: https://github.com/rackt/react-router/blob/v0.11.6/examples/query-params/app.js , you need to add the Router.State mixin:

var User = React.createClass({
  mixins: [ Router.State ],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM