`@void/solid`: `useParams()` keeps the first page's params after client-side navigation
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
- 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
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/void
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
voidzero-dev/void#677 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Export a guard for `VoidActionError` at every statusCó thể đã có người làm @karthickeyan-dev đã nhận hôm nay. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 78/100
voidzero-dev/void#714 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
voidzero-dev/void#713 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
voidzero-dev/void#692 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
voidzero-dev/void#689 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/void
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 2 ngày
-
reproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
anomalyco/opencode#62052 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
strapi/design-system#2084 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Report: &TV InternationalĐang mởcheck:passed streams:remove
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
OAuth documentation for GET /api/v2/users/me/ appears inconsistent with required global read scopeĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày