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
vicious-gold
vicious-gold2y 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 😄
extended-salmon
extended-salmon2y ago
No, I tried directly. This solves my problem. Thank you.
vicious-gold
vicious-gold2y ago
your welcome, I'm glad to hear that 🙏
More Posts
duplicate value i dont want to posti am having a form and i posting name . so i dont i want to post duplicate name another time . it shCan I display a list of posts within a category?In this format: `categories/1/posts` I see only option: `categories/posts` https://refine.dev/docs/aHow are supabase tables supposed to be created?I did not find any explanation in the documentation who manages the database, or at least informatioHow to transform form data before passing it to data provider?I have an edit page that should only send changed fields to the server instead of the whole form datFirebase with refine-firebase is not working with 3.x.xI tried both packages `refine-firebase` and `ketenburhan/refine-firebase` `ketenburhan/refine-fireInvalidating the service worker cacheAfter using `useUpdate` to modify a resource, the list view resends the `GET` request, but it still making custom errorNotification in mutate function under useDelete hookI'm getting this error on trying to delete an entry. Foreign key violation. update or delete on tabSupabase Auth UI with refine!I would like to use the default AuthUI from supabase with the refine! Is there a stackblitz for thatHow to change the label and icon of the default button that goes back to list in ShowIn the attached example, instead of "POSTS" I want it to be "Back to List" with different icon. ThanChanging the theme of refine MUI with some paid themesHi! We have used refine framework with MUI using the default layout and we are planning to shift to