Answer the question
In order to leave comments, you need to log in
`
Why does history have type any?
Why is history of type `History<any>`
;
function BasicExample() {
return (
<Router>
<div>
<Link to="/about/product">About</Link>
<Route exact path="/about/:product" component={RouteProduct} />
</div>
</Router>
);
}
const RouteProduct = withRouter(
({ match, history }: RouteComponentProps<{ product: string }>) => (
<Fragment>
10
</Fragment>
)
);
Answer the question
In order to leave comments, you need to log in
If you are working through an IDE, then going through the type chain you will see that History is:
and LocationState in turn:
In theory, the type should be overridden by the third argument of RouteComponentProps, but this does not work for me. Perhaps a bug.
Also, the withRouter wrapper is not needed in your example.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question