Getting Module ‘”react-router-dom”‘ has no exported member ‘RouteComponentProps error when migrating to react-router v6

We are having legacy class based code for which we are trying to migrate to latest react router that is version 6. During migration we are getting this error, Module '"react-router-dom"' has no exported member 'RouteComponentProps. We have added withRouter wrapper to add the legacy support.

import { useLocation, useNavigate, useParams } from "react-router-dom";

function withRouter(Component) {
  function ComponentWithRouterProp(props) {
    let location = useLocation();
    let navigate = useNavigate();
    let params = useParams();
    return <Component {...props} router={{ location, navigate, params }} />;
  }

  return ComponentWithRouterProp;
}

export default withRouter;

Our class based component looks like this,

import { Route, RouteComponentProps, Routes } from "react-router-dom";

class App extends React.Component<{} & RouteComponentProps<{}>, IState> {
  constructor(props: RouteComponentProps<{}>) {
    super(props);
    this.state = {
       prop1: null
    };
  }
   
  componentDidMount() {
    if (this.props.location.pathname === "/test") {
      window.location.reload();
    }
  };

   
  render() {
     return (
          <Routes>
               <Route path="/test" element={<Test />} />
          </Routes>
     )
  }
 }
 
export default withRouter(App);

How do I fix this issue?