react-router – pass props to handler component

If you’d rather not write wrappers, I guess you could do this:

class Index extends React.Component { 

  constructor(props) {
    super(props);
  }
  render() {
    return (
      <h1>
        Index - {this.props.route.foo}
      </h1>
    );
  }
}

var routes = (
  <Route path="https://stackoverflow.com/" foo="bar" component={Index}/>
);

Leave a Comment