Dynamic `href` prints console warning in development mode
See original GitHub issueBug report
Describe the bug
When using the new support (v9.5.3) for dynamic href (ie, <Link href="/pages/1">
when referring to pages/[id].js
, a warning is printed to the console:
Unknown key passed via urlObject into url.format: searchParams
To Reproduce
Here’s a minimal repro: https://github.com/ztanner/next-dynamic-link-bug – run yarn dev
and observe the console on the index page.
Expected behavior
No warnings should be printed
Screenshots
Dropping a debugger in the validator:
Additional context
The validation is coming from this section: https://github.com/vercel/next.js/blob/canary/packages/next/next-server/lib/router/router.ts#L566-L573 which implies searchParams
is potentially valid URL option, and shouldn’t be a warning?
Happy to jump on a solution to this - just want to verify that either searchParams
is valid, or alternatively it can be plucked out before being sent to the validator.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:9 (3 by maintainers)
Top GitHub Comments
@styxlab I just checked, it is fixed on
next@9.5.4-canary.2
. Either upgrade to canary, or wait until it gets to stable9.5.4
You can use it without warning like this :
<Link href="/pages/[id]" as="/pages/1">
as is the path that will be rendered in the browser URL bar.