Shared `useAsyncResource` hook for loading, error and retry state

オープン
#160 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
52/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
nextjs, react, typescript
領域
frontend

調査の方向性

Start by reading the loading, error and retry logic in web/app/dashboard/page.tsx, then compare it with the same pattern in web/app/history/page.tsx, web/app/activity/page.tsx and web/app/pay/[id]/page.tsx. Create the shared hook in web/lib/ with the signature useAsyncResource(fetcher, deps) returning { data, loading, error, reload }. Done means all four pages use it with unchanged skeletons, error alert and retry, unmount and stale responses are handled, and lint and build pass. Check with #16 and #90 first, since they touch the same loading behaviour.

索引モデルが issue の本文から書いたものです。

説明

difficulty: intermediate help wanted refactor web

Difficulty: Intermediate

Problem

The Dashboard, History, Activity and Pay pages each re-implement the same pattern: loading, error, a load callback with useCallback, an effect to call it, and a Retry button.

Why it matters

Duplicated state handling causes inconsistent behaviour and makes features such as caching or polling harder to add in one place.

Scope of work

Create a small hook (for example useAsyncResource(fetcher, deps) returning { data, loading, error, reload }) and migrate the four pages without changing visible behaviour. A data-fetching library is deliberately out of scope here.

Expected outcome

One tested hook replaces four copies of the same logic.

Acceptance criteria

  • All four pages use the hook with unchanged behaviour (loading skeletons, error alert, retry).
  • The hook handles unmount and stale responses safely.
  • Lint and build pass.

Relevant files

  • web/app/dashboard/page.tsx, web/app/history/page.tsx, web/app/activity/page.tsx, web/app/pay/[id]/page.tsx, web/lib/ (new hook)

Dependencies

Coordinate with #16 and #90, which also change loading behaviour.

Maintainer discussion needed?

No.

主要言語
TypeScript
スター
0
フォーク
4
平均マージ
54分
マージ済み PR(30日)
6

環境構築

はじめの一歩

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

Yormee-103/PayLoop のほかの issue

Yormee-103/PayLoop の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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