question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

So, I tried to get the Animated Switch working, but I got this error message. I did some research and found out that useLocation is exported from react-router, but not react-router-dom. I switched the rrt package to import from react-router instead and I got a Route that was positioned absolutely so that everything that is supposed to be beneath it was behind it.

Basically, my footer was up where it says “Projects” image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
josh231101commented, Mar 10, 2021

Simple solution inside your parent component that renders the route

useEffect(() => { window.scrollTo(0, 0); }, [])

1reaction
SaniJasicommented, Dec 5, 2019

Please update react-router-dom for the latest version!

Read more comments on GitHub >

github_iconTop Results From Across the Web

'useLocation' is not exported from 'react-router-dom' - Stack ...
Try uninstalling and reinstalling the "react-router-dom" Then, for safety, run npm i ...
Read more >
'uselocation' is not exported from 'react-router-dom'. - You.com
Attempted import error : 'useLocation' is not exported from 'react ... ... react-router-dom is a peer dependency, with a minimum major of 5....
Read more >
How To Fix - "Attempted Import Error: 'Switch' is Not Exported ...
In this post, we will see How To Fix – “Attempted Import Error: 'Switch' is Not Exported From 'react-router-dom' in React.js, React-Router-Dom.
Read more >
'useHistory' is not exported from 'react-router-dom' SOLVED
How to solve Attempted import error : 'useHistory' is not exported from 'react - router - dom ' and useHistory was not found...
Read more >
How to Fix Attempted Import Error Switch is Not Exported From ...
Command:- npm install react - router - dom @5.3.0In This Video We Will See How to Fix Attempted Import Error Switch is Not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found