`@void/solid`: `useParams()` keeps the first page's params after client-side navigation
维护者通常 1 天内回复
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 20/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- typescript
- 领域
- frontend
调研方向
Read packages/solid/src/plugin-pages.ts around the ParamsContext.Provider and applyUpdate code referenced in the issue. The issue describes the stale context value and points to the existing in-place update for shared as a possible pattern; compare it with the fix in #709. Done means useParams() returns the current route params after navigation and browser back.
由索引模型根据 Issue 内容生成。
描述
Problem
In a Solid pages app, useParams() keeps returning the params of the first page rendered, for the rest of the session. useRouter().params on the same page returns the correct values.
Reproduction
https://github.com/yujiym/void-solid-useparams-repro
pnpm install
pnpm dev
- Open
/cards/xyzdirectly. - Click Home, then /cards/abc.
- Click /cards/def.
- Press the browser's back button.
| Step | useParams().slug |
useRouter().params.slug |
|---|---|---|
Load /cards/xyz directly |
xyz |
xyz |
Home, then /cards/abc |
xyz (stale) |
abc |
/cards/def from the card page |
xyz (stale) |
def |
Browser back to /cards/abc |
xyz (stale) |
abc |
The browser console shows no errors.
Expected behavior
useParams() returns the params of the current page, matching useRouter().params.
Cause
The generated Solid client provides the params like this (packages/solid/src/plugin-pages.ts):
createComponent(ParamsContext.Provider, {
get value() { return routeParams(); },
Solid's context provider reads props.value inside untrack when it is created, so the getter doesn't subscribe to routeParams. The context keeps the first params object, even for pages created after a navigation.
useRouter().params reads the routeParams signal directly, which is why it stays correct.
Possible fix
Provide a stable createMutable object and update it in place in applyUpdate, as this file already does for shared. #610 fixed the same symptom in @void/svelte by updating its params object in place.
I'm happy to open a PR. Opened in #709.
Environment
voidand@void/solid1.6.1; the same provider code is onmainat 5d2a2ff5- Also reproduced on 1.4.0 and 1.5.0
solid-js1.9.18, Node 24, pnpm 11.20.0vite dev, headless Chromium
- 主要语言
- TypeScript
- 星标
- 627
- 派生
- 66
- 平均合并
- 13 小时 57 分钟
- 30 天内合并 PR
- 194
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/void 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
voidzero-dev/void#677 ·
维护者通常 1 天内回复
-
Export a guard for `VoidActionError` at every status可能已有人在做 @karthickeyan-dev 今天认领。 未关闭
难度 3/5 1-2 天 新手友好度 78/100
voidzero-dev/void#714 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 72/100
voidzero-dev/void#713 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 28/100
voidzero-dev/void#692 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 30/100
voidzero-dev/void#689 ·
维护者通常 1 天内回复
查看 voidzero-dev/void 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
Open-Earth-Foundation/CityCatalyst#3399 ·
维护者通常 2 天内回复
-
userReport
难度 1/5 1 小时以内 新手友好度 72/100
nkprasad12/morcus-net#631 ·
维护者通常 1 天内回复
-
fix(app): fail closed if GetGeneralSetting fails during initialization可能已有人在做 @kalavt 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
nekko-labs/nekko-agent#1756 ·
维护者通常 1 天内回复
-
needs-area-label
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 2 天内回复