react-router v5.1.0 Cannot read property 'location' of undefined ,
You need to move BrowserRouter
out of that component. The best is to move it to index.js
and enclose <App />
You're using useLocation
outside the components wrapped by the router, in your case the root component (inside app.js
) is the wrapper of the router component
please check this you could see the difference when you use that hook in App.tsx
and QueryReducer
components.