router react typescript code example
Example 1: how to install react router dom with typescript
npm install react-router-dom @types/react-router-dom
# Yarn
yarn add react-router-dom @types/react-router-dom
Example 2: router react typescript
export interface RouteComponentProps {
history: H.History;
location: H.Location;
match: match;
staticContext?: C;
}
export interface RouteProps {
location?: H.Location;
component?: React.ComponentType> | React.ComponentType;
render?: ((props: RouteComponentProps) => React.ReactNode);
children?: ((props: RouteChildrenProps) => React.ReactNode) | React.ReactNode;
path?: string | string[];
exact?: boolean;
sensitive?: boolean;
strict?: boolean;
}
export class Route extends React.Component { }