Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<PrefectureCheckbox>の値がOptimistic updateされるようにする #34

Open
ReoHakase opened this issue May 26, 2024 · 2 comments
Open
Assignees
Labels
✨ feat 機能の実装。

Comments

@ReoHakase
Copy link
Owner

ReoHakase commented May 26, 2024

概要

現状の問題点

都道府県チェックボックス<PrefectureCheckbox>の値を押して変更しても、サーバー側でRSCがレンダーされて返却されるまでURLが書きかわらない。そのため、瞬時にチェックボックスの値が更新されない。また、URLが書き変わる前に再度他のチェックボックス<PrefectureCheckbox>を押しても、遷移先が最初の都道府県チェックボックスによる値を含まないものになってしまう。

解決法

1. /[statLabel]のfetch処理を<Suspense>内に移す

サーバー側の修正では対応不可能

2. <PrefectureCheckbox>にステートを追加してOptimistic Updateを実装する

<PrefectureCheckbox>の間で共有ステートを作る必要がある。

  • Context
  • Jotai
  • 親Client Componentを作り、親からイベントハンドラを渡す
@ReoHakase
Copy link
Owner Author

テストが楽そうなのは、

親Client Componentを作り、親からイベントハンドラを渡す

実装が楽そうなのは、

Jotai

@ReoHakase ReoHakase added ✨ feat 機能の実装。 and removed enhancement labels May 31, 2024
@ReoHakase
Copy link
Owner Author

まずは #58 を試してみることにします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feat 機能の実装。
Projects
None yet
Development

No branches or pull requests

1 participant