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

Đang mở
#708 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@yujiym đang làm issue này rồi.

Từ ngày 4/11/2026.

  • #709 của @yujiym — đang mở

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
20/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
TypeScript
Star
627
Fork
66
Merge trung bình
13 giờ 57 phút
Pull request đã merge (30 ngày)
194

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của voidzero-dev/void

Tất cả issue của voidzero-dev/void

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.