Replies: 2 comments 1 reply
-
ex: import { forwardRef } from 'react';
import { Link as ReactRouterLink, type LinkProps } from 'react-router-dom';
import { useGlobalState } from '@global/context/global-state/useGlobalState';
/**
* Wraps the `Link` component from react-router: https://reactrouter.com/en/main/components/link
*
* The difference is that our version will turn into a real anchor tag to force a full page load if a new
* version of the webapp is available.
*/
export const Link = forwardRef<HTMLAnchorElement, Omit<LinkProps, 'href'>>(
({ to, children, replace, reloadDocument, ...props }, ref) => {
const { fullPageloadNeeded } = useGlobalState();
return (
<ReactRouterLink
ref={ref}
to={to}
replace={replace}
reloadDocument={fullPageloadNeeded || reloadDocument}
{...props}
>
{children}
</ReactRouterLink>
);
}
);
Link.displayName = 'Link'; but w/ tanstack router 😁 |
Beta Was this translation helpful? Give feedback.
0 replies
-
we have this now in https://github.com/TanStack/router/releases/tag/v1.88.0 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A useful (though seemingly undocumented) feature of the ReactRouterv6
<Link>
/<NavLink>
components is thereloadDocument
prop, which will do a traditional navigation for the link provided rather than an SPA navigation.https://github.com/remix-run/react-router/blob/f85e0b33536645aa14c9d7cc6e3f9e09f63373da/packages/react-router-dom/index.tsx#L483
This is would be helpful for example when you want to implicitly upgrade an SPA's deployed version, without prompting the user to reload their browser or press a "upgrade app version" button.
Beta Was this translation helpful? Give feedback.
All reactions