-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Cannot read properties of undefined (reading 'pathname'). React Router 6 #8489
Comments
Can you share a code example? |
@olegKusov are you using Router or BrowserRouter? |
I am having the same problem but I am not sure what is causing. I tried to create the error on sandbox but I had no luck. Version of history package: 5.1 I am using HistoryRouter like described #8264 (comment) If I change it to BrowserRouter it works but I need to pass history object to use it outside of components. It happens when I navigate through sidebar with useNavigate or go back and forward with browser. |
Can someone with this issue please post a code example? Preferably on Stackblitz or Codesandbox. I'm not sure how it's happening, but the history instance you're passing in doesn't have a |
I'll try to reproduce this error. |
What version of React Router are you using? I managed to fix this issue by |
Without a reproduction, this is likely due to an incorrect version of history being applied somewhere. Until someone can point to the specific cause, I don't think this is an issue with the library itself. |
For anyone stumbling upon this. I encountered this error when converting my Next js Make sure you aren't an idiot like me, and check you are using |
Today I discovered that I am an idiot. Thanks for the tip. |
import {useLocation} from 'react-router-dom' // v6.2.1 const {pathname, search} = useLocation() Then got an error |
Hi, Here's my code: index.js:
App,js
Errors are as follows:
Consider adding an error boundary to your tree to customize error handling behavior. Here's my git --> https://github.com/WalterOkumu/react-admin-tutorial |
I have encountered this problem, because of I use import { ConnectedRouter } from 'connected-react-router'; |
Experiencing the same behavior on
Error as follows:
|
Try to remove node-modules and do |
Maybe you could refer to this article : https://bobbyhadz.com/blog/react-cannot-read-property-pathname-of-undefined |
What version of React Router are you using?
6.1.1
Version of history package: 5.1
Steps to Reproduce
I'm using useNavigate, useHistory, useLocation, , and maybe something else.
Expected Behavior
No error
Actual Behavior
The text was updated successfully, but these errors were encountered: