-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
RR7 lazyRouteDiscover (Fog of War) opt-out #12656
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
Comments
Same here. Would love to see a way to opt out the feature or configure it. |
We need more control over Fog of War. I noticed the same issue, we have a search results page where each result is a different link. React Router fetches a manifest for all the links, but it's just a single route with parameters. It would be great to have some way to exclude links from discovery and just use whatever is already loaded. The initial manifest only contains the matched routes. Therefore a manifest is always fetched on page load. We should have an (optional) option to eagerly load those as well. |
I digged a bit deeper in source code and it seems there is only 1 solution - use For an example // Main navigation
<Link to={'/'}>Home</Link>
<Link to={'/products'}>Products</Link>
<Link to={'/login'}>Login</Link>
<Link to={'/register'}>Register</Link>
...
// Filters
<Link to={'/products?color[]=blue'} discover={'none'}>Blue</Link>
<Link to={'/products?color[]=red'} discover={'none'}>Red</Link>
<Link to={'/products?color[]=red&color[]=blue'} discover={'none'}>Blue</Link> // in case red is active already
<Link to={'/products?color[]=blue&color[]=red'} discover={'none'}>Red</Link> // in case blue is active already
// Pagination
<Link to={'/products?page=2'} discover={'none'}>2</Link>
// Products
{items.map((item, key) => (
<Link to={`/products/${item.slug}`} discover={key === 0 ? 'render' : 'none'}>
<ProductCard item={item} />
</Link>
))} However, it gets really messy and hard to maintain such a mayhem project in the future. Let's hope to hear authors thoughts soon. |
I agree, adding discover="none" to all |
+1. In my case it's causing my tests to fail during my v7 upgrade, because my assertions didn't expect the new Example of a typical test failure in a jest snapshot test
As a workaround, I have a helper file with a wrapper for the React Router Link component that sets // assets/src/util/react-router.tsx
import {
LinkProps,
NavLinkProps,
Link as ReactRouterLink,
NavLink as ReactRouterNavLink,
} from "react-router";
/**
* Use this instead of the normal react-router Link
*
* React Router's lazy loading / link discovery feature
* by default adds a `data-discover="true"` attribute to every link.
* This opts out of that feature, but must be done for every link
* individually, hence this helper.
*
* It can be removed if they ever implement a global opt-out of this feature.
* https://github.com/remix-run/react-router/issues/12656
*/
export const Link = (props: LinkProps) => (
<ReactRouterLink discover="none" {...props} />
);
export const NavLink = (props: NavLinkProps) => (
<ReactRouterNavLink discover="none" {...props} />
); If this global opt-out is added, I can use that instead and delete my wrapper. |
+1 for opting out of this feature. I have offline-first web-app and this feature is complicating things for me. I have to build custom manifest file based on the routes. |
You probably should not apply |
My app is not large, I don't do (and don't want to do) any code splitting or lazy loading. |
It's nothing to do with lazy loading or code splitting. When you disable the route manifest entirely (which is what you currently do by using That's the problem with the issue: we are not able to load the whole route manifest on the initial load like before. |
This is also giving us a lot of trouble. I've even encountered a race condition which renders an error. Looks like it happens because there is a request for manifest of route A going in parallel to a navigation to route B. We also have very few routes (but a lot of links with different params), so the strategy in the old Remix where it would get manifest of all routes in one request at startup would be much better for performance (and number of request to the server). |
@mjackson @brophdawg11 @ryanflorence Thoughts? By today, it's clear that the issue should be categorized as a 'bug' instead of 'docs'. |
I only have a 29kb uncompressed manifest file after build. But I have a page with a lot of Even the react router doc site is calling /__manifest every time you click to navigate. FOW sure is a huge optimization for bigger site, but for a small or medium site, the network fetch overhead is also huge. It would to nice to opt out and load the entire manifest during initial page load. |
I too would like the option to just download the entire manifest in one go instead of needing to add |
I also want a way to disable Fog of war. I'm migrating a remix v2 app to react-router. This app has ~30 routes where in many of them we're using This issue provides a workaround but it doesn't work for me (the request is not properly formatted). I can debug and figure out what's wrong, but I don't want to do this workaround foreach of the routes that might be called by a I don't have that many paths to begin with and the |
We introduced a new |
🤖 Hello there, We just published version Thanks! |
Missing information how to disable lazy route discover (also known as Fog of War) feature.
In my case, it causes unnecessary overhead on application which renders thousands of links (filters and products) but there are only 7 RR routes in total. Would love to disable the feature.
The text was updated successfully, but these errors were encountered: