Skip to content

Instantly share code, notes, and snippets.

@russellr922
Created January 9, 2020 00:08
Show Gist options
  • Save russellr922/431a782249b95013d79972868dc0d446 to your computer and use it in GitHub Desktop.
Save russellr922/431a782249b95013d79972868dc0d446 to your computer and use it in GitHub Desktop.
React-Router TypeScript RouteComponentProps without importing throughout entire app.
// Reference "Router.RouteComponentProps" in any file without having to import.
// i.e. const MyReactComponent: React.FC<Router.RouteComponentProps> = (props) => (<div>{props.location.pathname}</div>);
// The code below goes into a file named "react-router.types.d.ts" this should go in the same directory as "react-app.env.d.ts" or your global definitions.
import { RouteComponentProps as IRouteComponentProps } from "react-router-dom";
export interface RouteComponentProps<T = {}> extends IRouteComponentProps<T> {};
export as namespace Router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment