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

2
closed
sytpb
sytpb
Posted 1 month ago

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

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 ?

lamhungypl
lamhungypl
Created 1 month ago

codesandbox reproduce, please!

sytpb
sytpb
Created 1 month ago

upgrade the react-router-dom fixed this issue . i have just got the point , is the "react-router-dom": "5.0.1", the version 5.0.1 is not support useLocation, update to 5.3 ,it worked .

thanks a lot !