Loading...
Loading...
React 19.3 のコンポーネント、ローダー、サーバー処理を書く・直す・レビューするときに読む。非同期の瀑布を消し、状態を Effect Atom と TanStack Query に置き分け、Effect・トランジション・Suspense・Activity・ViewTransition・useEffectEvent の使いどころとコンポーネントの props の形を決める。
npx skill4agent add masseater/skills how-to-use-react| やりたいこと | 使うもの | 使わないもの |
|---|---|---|
| 画面の一時状態、フォームの値、ツリーをまたいで共有する値 | Effect Atom( | |
| サーバーデータ | TanStack Query( | |
| ミューテーションの pending と error | TanStack Query の | 自前の pending フラグ、 |
| 順番が仕様のミューテーション | 同じ | 自前のキュー、ボタンを無効にして操作列を止める |
| 楽観更新 | | 自前の巻き戻し状態 |
| 急がない更新・重い派生 | | タイマーデバウンス |
| ref | 関数の props | |
| 隠しても状態を残す | | 条件付きアンマウントで状態を捨てる |
| 遷移のアニメーション | | |
| Effect で最新の props を使う | | その関数を依存配列に足して購読をやり直す |
useMemouseCallbackmemoreact-perfuseCallbackuseMemoreferences/effects-and-data.mdreferences/design-theory.mduseOptimisticreferences/action-queue.mduseDeferredValuereferences/deferred-consistency.md<Activity><ViewTransition>useEffectEventreferences/concurrent-ux.mdreferences/component-apis.mdreferences/naming.mdreferences/async.mdEffect.allEffect.forEach{ concurrency: "unbounded" }{ concurrency: 1 }Promise.allEffect.flatMapEffect.allconst loaded = Effect.all(
{
config: fetchConfig,
profile: fetchUser.pipe(Effect.flatMap((user) => fetchProfile(user.id))),
},
{ concurrency: "unbounded" },
);| 原典 | 代わり |
|---|---|
Next.js( | TanStack Start のローダー |
| SWR | TanStack Query |
| |
| |
| ハンドラを ref にしまう | |
| Redux の Action / Reducer / Selector | Effect Atom と TanStack Query、FSD の |