Am developing single page application using React. Am using react-router v6 for routing.
currently am using useLocation() hook to get current path name in root app.
So suppose on path '/A' render component 'A'.
In component 'A', am navigating to '/A/:id'. Because there is an update in url, now useLocation() called again. And re-render again. hence the process repeat again. going to component 'A' and navigate() called again.
Hence its stucked in loop. Can anyone provide any solution for it.
window.location.pathname returns the current path, you don't need hooks for it.