mute-gold•7d ago
I can't find in document, what happened useTitle,useRouterType,useRefineContext - hasDashboard,etc.
What could i use intead of these functions?
useRouterType
useRouterContext
const { hasDashboard } = useRefineContext(); //hasDashboard?
useTitle()
useLocation()
11 Replies
Hi @Juncture. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources, I can help you understand what happened to these hooks and what to use instead:
Deprecated Hooks and Their Replacements
useRouterContext
This hook is deprecated and only works with the legacy router provider. According to the migration guide, you should replace it with these hooks based on your use case:
- useGo - for navigation
- useParsed - for parsing route parameters
- useBack - for going back
- useLink - for getting the Link component
Example replacement:
useRouterType
I'm sorry, but there's no information about useRouterType in the provided knowledge sources.
hasDashboard from useRefineContext
The knowledge sources mention that the DashboardPage prop is now deprecated in the new router providers. According to the router provider migration guide, you need to create your own index route for your dashboard and use the resources array to add this item to your <Sider> menu.
useTitle
The knowledge sources do not explicitly mention what happened to useTitle or its replacement.
useLocation
The knowledge sources do not provide specific information about useLocation being deprecated or its replacement, though the routing system has changed significantly in v4.
Important Context
With the new router provider in Refine v4, routing behavior has changed significantly. Refine no longer creates routes internally, giving you freedom to create routes according to your framework. Tasks like authentication and access control are now decoupled from Refine and should be handled using:
- The Authenticated component or useIsAuthenticated hook for authentication
- The CanAccess component or useCan hook for access control
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@248863890190893057> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
mute-goldOP•7d ago
@kapa.ai How can i use properly
<ListItemButton
component={Link}
to={route}
....
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on the knowledge sources, I can help you use
ListItemButton with the Link component properly.
Using ListItemButton with Link
The issue you're encountering is related to the Link component needing to forward refs. According to a GitHub issue about this exact problem, when using Link with Material-UI's ListItemButton, you need to ensure the Link component properly forwards refs.
Solution
You should use the Link component from @refinedev/core with forwardRef. Here's how to create a custom Link component that works with Material-UI buttons:
Then use it in your component:
The key is that the Link component must be wrapped with React.forwardRef and pass the ref prop to the underlying link component, as Material-UI's ListItemButton expects a component that can receive a ref prop.
This solution is based on the custom router provider configuration example and addresses the ref forwarding issue with Material-UI buttons.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@248863890190893057> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
mute-goldOP•7d ago
@kapa.ai I use
import { Link } from "@refinedev/core";
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on the knowledge sources, when you use
import { Link } from "@refinedev/core";, you're importing Refine's Link component that works with your configured router provider.
How it Works
The <Link /> component from @refinedev/core uses routerProvider.Link under the hood. According to the Link component documentation, if a routerProvider is not provided, it will fall back to using the standard <a> HTML element.
Usage with Material-UI ListItemButton
Since you're using the Link from @refinedev/core, you can use it directly with Material-UI's ListItemButton:
Type Support
If you need TypeScript support for your specific routing library, you can use generics with the Link component. According to the Link documentation, here's an example:
The Link component from @refinedev/core should work properly with Material-UI components as long as your routerProvider is configured correctly with a Link component that forwards refs, which is the standard behavior in modern Refine router providers.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@248863890190893057> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
mute-goldOP•7d ago
@kapa.ai but i won't work

Let me check the knowledge base for you again. One moment! :books:
----------------------
I understand you're experiencing issues with using the
Link component from @refinedev/core with Material-UI's ListItemButton. Let me help you troubleshoot this.
Potential Issues and Solutions
Based on the knowledge sources, there are a few common issues that could prevent this from working:
1. Router Provider Configuration
First, ensure you have a routerProvider properly configured in your <Refine /> component. According to the Material-UI integration documentation, you need to import and configure the router provider:
2. Custom Link with forwardRef
If you're still having issues, you may need to create a custom router provider with a properly configured Link component that forwards refs. According to the GitHub discussion about router provider configuration, you can override the Link component:
3. Check Your Setup
Could you provide more details about:
- What error message you're seeing?
- Which router provider you're using (React Router, Next.js, etc.)?
- The exact code where it's failing?
This will help me provide a more specific solution based on the knowledge sources available.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@248863890190893057> Kapa.ai is still learning and improving, please let me know how I did by reacting below.