qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[🐞] Use location params does not exist

Open adamgen opened this issue 1 year ago • 2 comments

Which component is affected?

Qwik City (routing)

Describe the bug

With the current https://qwik.new/ template, open the flower example and see this error:

37 |            class={{
38 |              host: true,
39 |              pride: loc.query.get('pride') === 'true',
   |    ^
40 |            }}
41 |          >

Reproduction

https://stackblitz.com/edit/qwik-starter?file=src%2Froutes%2Fdemo%2Fflower%2Findex.tsx

Steps to reproduce

No response

System Info

1. Open demo
2. Click on the `Flower App` link

Additional Information

Seems that the useLocation is missing the query when it should appear there, I haven't look at the source yet.

adamgen avatar Apr 16 '23 07:04 adamgen

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

stackblitz[bot] avatar Apr 16 '23 07:04 stackblitz[bot]

It might have changed at some point, but loc.url.searchParams.get('pride') is what would work with the latest Qwik I think.

cmbartschat avatar Apr 21 '23 23:04 cmbartschat

This seems to have been fixed in the current version.

ehrencrona avatar Jun 23 '23 14:06 ehrencrona

I am having the same issue with SSG using qwik v1.2.7. I have a page at /order/view/?id=7, when I use a Link to navigate to that page then loc.url.searchParams.get('id') will correctly return '7' but when I reload/refresh the page or directly navigate to the page then it will return a null. Currently I am using this to solve the issue: new URL(document.URL).searchParams.get('id'). This issue does not appear on pnpm dev mode, it works correctly. It appears only in SSG using pnpm build then serve the dist folder using nginx.

lbensaad avatar Aug 15 '23 17:08 lbensaad

@adamgen is it still an issue?

@lbensaad can you please open up a new issue with we repo showing your specific issue?

shairez avatar Aug 15 '23 19:08 shairez

The demo works fine; I'm closing it. 👍🏼

adamgen avatar Aug 16 '23 02:08 adamgen