-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] - React Browser Router - Link always reload whole page #4897
Comments
Hey there! This is not a bug. There's two ways to fix this. import {Link} from "react-router-dom";
export default function YourButton(){
return (
<Button as={Link} to="/yout/path">Button</Button>
)
} And the other one it's using import type {NavigateOptions} from "react-router-dom";
import {BrowserRouter, useNavigate, useHref} from "react-router-dom";
import {HeroUIProvider} from "@heroui/react";
declare module "@react-types/shared" {
interface RouterConfig {
routerOptions: NavigateOptions;
}
}
function App() {
const navigate = useNavigate();
return (
<HeroUIProvider navigate={navigate} useHref={useHref}>
{/* Your app here... */}
<Routes>
<Route path="/" element={<HomePage />} />
{/* ... */}
</Routes>
</HeroUIProvider>
);
} PD: I think you're missing adding useHref of your global provider. Take a look to the docs setting up React Router with HeroUI. documentation |
@komenixx Please try to add |
@wingkwong adding I simply override default HeroUI. Working solution is using Link from react-router-dom, by @iSaulX |
Same issue in Next.js regarding full page reloads. Here is a summary: in providers.tsx:
then when using in component:
|
Works now, update everything of heroui to latest |
HeroUI Version
2.7.2
Describe the bug
useNavigate
has no effect on howLink
component handle routing behavior.App.tsx
Component.tsx
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
react-router-dom
Link
orButton
withas Link attribute
Expected behavior
I expect browser routing behavior without reload whole page.
Screenshots or Videos
No response
Operating System Version
macOS
Browser
Chrome
The text was updated successfully, but these errors were encountered: