While using react-router-dom 5.3.0, I am opening a modal but am not changing route, and this error appears.
I have since downgraded react-router-dom to 5.2.0 and this error does not appear.
Any help is much appreciated :-)
I had the same error after upgrading the react-router-dom version when I tried accessing the current URL with location.pathname .
Using the useLocation() hook solved my problem:
import { useLocation } from 'react-router-dom';
// getting current pathname with custom hook
const useName = () => {
const location = useLocation();
return location.pathname;
}
context.locationis not definedcreatePath(context.location)? It calls the functioncreatePathand inside it, the line 47 location is undefined. Socontext.locationis undefined.... In your code, you can wait thatcontext.locationhas a wanted value...