typescriptreact-routerreact-router-v4

Where can I find types for react-router-dom Location, History and Match?


When I use withRouter from react-router-dom v4.3.2, it passes three props to the component, history, match and location. Where can I find the type definition for these three objects for TypeScript?

I have checked this link https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-router/v3/lib but it doesn't have version 4. In addition, the type defined there doesn't include History location and match.


Solution

  • import { History, Location } from 'history';
    import {match} from 'react-router';
    

    You can check out @types/react-router. There you can see all the types defined and imported from @types/history.