<PrefetchPageLinks /> crashes the page when there is a query param in the URL
See original GitHub issueWhat version of Remix are you using?
1.6.1
Steps to Reproduce
- Add a
<PrefetchPageLinks />
to an active route. - Add some query params to your URL ie
?query
and hit return to reload the page - Observe:
Expected Behavior
I would expect the page to load, unless there’s some behavior with PrefetchPageLinks I was not aware of where it can’t be rendered on a page with query params.
Actual Behavior
The page crashes and we see the following window is not defined error
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Page crashing from '#' as a GET-parameter - Stack Overflow
Whenever you create URL to be displayed in the browser it has to be urlencoded. If you are just appending the query string...
Read more >Data Loading - Remix
URL Search Params are the portion of the URL after a ? . Other names for this are "query string", "search string", or...
Read more >Fixing Next.js router query param returning undefined on ...
for a lot of time, the page kept crashing. When I saw your code, it immedeately clicked in my mind, why not do...
Read more >Appending the referrer's query string to the curre...
I'm looking to keep URL query string parameters. ... It's also good that he mentioned both pages are running over SSL (https), ...
Read more >How to Access the URL Params in React with React Router's ...
This guide walks through how to utilize React Router's useParams hook to get access to the URL params data for a route, such...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
tracking this internally now, and I plan to look into it today!
edit: OP actually has a potential fix for this via #3791
edit 2: actually looking over this more, the issue at hand is we use window in
PrefetchPageLinks
so we can get the current url as well as get the proper links depending on media queries, but i know we have a internal ticket for that already. Usage in theLink
component is to conditionally rendered depending on intent https://github.com/remix-run/remix/blob/142aedc69b62633c4a6ebd49c0ae333255aa5d5a/packages/remix-react/components.tsx#L499 - but gonna look into a broader fix for this, first thought is return early iftypeof document === "undefined"
as ideally we don’t render these during SSR, but we’ll see@mcansh I can conditionally render it but we’re using it to help a slow endpoint so it would be preferred to use it across the board. Right I’m doing something like
{!location.search && <PrefetchPageLinks />}