Created
January 9, 2020 00:08
-
-
Save russellr922/431a782249b95013d79972868dc0d446 to your computer and use it in GitHub Desktop.
React-Router TypeScript RouteComponentProps without importing throughout entire app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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