will
will

Reputation: 235

Attempted import error: 'useLocation' is not exported from 'react-router-dom'

React version:
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-router-dom": "5.0.1",
"react-scripts": "3.4.0",

js code as

import {useLocation} from "react-router-dom";
const location = useLocation();

...... where is the problem ?

Upvotes: 2

Views: 7041

Answers (2)

Ankit Sanghvi
Ankit Sanghvi

Reputation: 527

Try uninstalling and reinstalling the "react-router-dom" Then, for safety, run npm i and npm start. Also, if you're using TS, you have to also install "@types/react-router-dom" as a dev dependency

Upvotes: -1

ray
ray

Reputation: 27245

That hook was added in 5.1.0.

Upvotes: 10

Related Questions