Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React: useLocation Hook doesn't exist in react-router-dom Typescript

Hello I'm trying to import useLocation Hook from react-router-dom "typescript" I can't find it

as per React Router Documentation I'm pretty sure it exists.

Yet in typescript it keeps telling me there is not exported member called useLocation

This is how I import it:

import { useLocation } from 'react-router-dom';

And this is the error I get:

Module '"../../node_modules/@types/react-router-dom"' has no exported member 'useLocation'.ts(2305)

like image 382
Willy Avatar asked Nov 07 '22 08:11

Willy


1 Answers

This is a typescript parsing error meaning the error is thrown by the package @types/react-router-dom and not the package react-router-dom, make sure you update and reinstall both.

like image 176
R01010010 Avatar answered Nov 15 '22 06:11

R01010010