Why are the react-router component props not including history?

Viewed 496

I'm loving v4 but in 4.1.2 this keeps tripping me up when using the browser router:

With a component in a Route component I have these props passed in: {computedMatch, location, path} although the documentation tells me to expect {match, location, history} which is what I get with the hash router.

To get the history passed in I have to use the withRouter wrapper which feels very clunky because the relevant component is the component prop to a Route component.

The documentation sounds right to me. Is this a bug?

1 Answers

You can get access to {match, location, history} if you use Route as

<Route path="/" component={myComponent} 

In above code you will have match location and history accessible inside myComponent.

Or else you have to use withRouter

Related