Using react-router-dom hooks

I want to use react-router-dom hooks but I get: useLocation() may be used only in the context of a <Router> component. It looks like the application is not wrapped in <BrowserRouter/>
3 Replies
provincial-silver
provincial-silver3y ago
Hi @a77ay,
are you using like this ?
import {
useRouterContext,
} from '@pankod/refine-core';


const ExampleComponent = () => {
const { useLocation } = useRouterContext();

return <div/>
}
import {
useRouterContext,
} from '@pankod/refine-core';


const ExampleComponent = () => {
const { useLocation } = useRouterContext();

return <div/>
}
If you are not, can you give me more detail of your environment ? for example: what is your @pankod/refine-core and @pankod/refine-react-router-v6 versions if u have @pankod/refine-cli installed, u can run npm run refine whoami and all env details will be listed. if you share with us, we can easily debug 🙏 if not installed npx @pankod/refine-cli whoami you can run this ofc 😄
ambitious-aqua
ambitious-aquaOP3y ago
No, I tried directly. This solves my problem. Thank you.
provincial-silver
provincial-silver3y ago
your welcome, I'm glad to hear that 🙏