useParams Hook Require Defined Type

  • Typescript can not recognize url parameters in useParams()
  • Need to define type1
import { useParams } from "react-router-dom";
interface RouteParams {
id: string;
}
const PatientPage: React.FC = () => {
const id = useParams<RouteParams>().id;
console.log({id});
return <div>Patient Info goes here</div>;
};