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

オープン
#708 コメント 0 件 リアクション 0 件 担当者 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分
マージ済み PR(30日)
194

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

voidzero-dev/void のほかの issue

voidzero-dev/void の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。