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

Abierto
#160 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
52/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
nextjs, react, typescript
Área
frontend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
0
Forks
4
Merge medio
54 min
PR fusionados (30 d)
6

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Yormee-103/PayLoop

Todos los issues de Yormee-103/PayLoop

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.