`@void/solid`: `useParams()` keeps the first page's params after client-side navigation

未关闭
#708 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@yujiym 已经在做这个了。

开始于 2026年11月4日。

  • #709 来自 @yujiym —— 未关闭

评估

难度
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
  1. Open /cards/xyz directly.
  2. Click Home, then /cards/abc.
  3. Click /cards/def.
  4. 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

  • void and @void/solid 1.6.1; the same provider code is on main at 5d2a2ff5
  • Also reproduced on 1.4.0 and 1.5.0
  • solid-js 1.9.18, Node 24, pnpm 11.20.0
  • vite dev, headless Chromium
主要语言
TypeScript
星标
627
派生
66
平均合并
13 小时 57 分钟
30 天内合并 PR
194

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

voidzero-dev/void 的其他 Issue

查看 voidzero-dev/void 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。