Class Component utilities for React Router 6+
https://idea2app.github.io/React-Router-class-tools/preview/
withRouter() functionwithRouter() decoratorRouteComponentPropsthis.props.historythis.props.locationthis.props.matchthis.props.query: the missing Query objectimport { PureComponent } from 'react';
import { RouteComponentProps, withRouter } from 'react-router-class-tools';
type RoutePageProps = RouteComponentProps<
{ id: string },
{},
{ extra: number }
>;
@withRouter
export class RoutePage extends PureComponent<RoutePageProps> {
render() {
const { id } = this.props.match.params,
{ extra } = this.props.query;
return (
<ul>
<li>ID: {id}</li>
<li>extra: {extra}</li>
</ul>
);
}
}