Is there any way in React-Router to console.log the path like so "users/:userId" (not "users/123") from the root component every time the route changes from anywhere in the app?
So for we have this, but can only print "users/123":
// ...
export default function App() {
useEffect(() => {
const unlisten = history.listen((location, action) => {
console.log(
`${action} ${location.pathname}${location.search}${location.hash}`
);
});
return () => {
unlisten();
};
}, []);
// ...
}