Skip to content

feat: migrate dashboard and setup components to React Query - #35

Merged
priscaenoch merged 1 commit into
octraban:mainfrom
jrcity:feat/react-query-migration
Jul 29, 2026
Merged

feat: migrate dashboard and setup components to React Query#35
priscaenoch merged 1 commit into
octraban:mainfrom
jrcity:feat/react-query-migration

Conversation

@jrcity

@jrcity jrcity commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

This PR significantly refactors the application's data fetching layer by migrating away from legacy useEffect polling and manual fetch calls. It introduces centralized React Query hooks across the dashboard and setup pages, ensuring better performance, automatic retries, strict typing, and substantially simplified component state management.

Key Changes

  • Global Configuration: Configured a QueryClient provider in src/main.tsx with optimized defaults (staleTime: 5000, retry: 3, refetchOnWindowFocus: false).
  • API Abstraction: Added missing endpoints (RPC metrics, admin analytics, setup endpoints) to src/api.ts with strongly typed request/response definitions.
  • Component Refactoring:
    • RpcMetricsDashboard: Replaced manual setInterval polling with useQuery's built-in refetchInterval.
    • RateLimitDashboard: Consolidated 4 parallel fetches into clean useQuery hooks. Removed complex Promise.all error handling and centralized 401 Unauthorized detection.
    • BatchMultiCall: Replaced raw POST requests with semantic useMutation hooks for simulate, estimate gas, validate, and optimize actions. Loading states are now smoothly derived from .isPending flags.
    • SetupPage: Form data is correctly populated from useQuery, and operations (database testing, initialization, config saving) are now handled by isolated useMutation hooks.
  • Testing: Added rigorous Vitest unit tests for RpcMetricsDashboard, explicitly covering loading, error, and success states with mocked API implementations.

Motivation and Context

The previous data-fetching architecture relied heavily on component-level useEffect hooks, leading to complex, boilerplate-heavy code prone to race conditions, memory leaks, and duplicate network requests. Leveraging @tanstack/react-query resolves these issues natively, offering a much more maintainable and production-ready pattern.

Verification

  • Linting passes locally (npm run lint - 0 errors)
  • All Unit tests pass (npm test - 147 tests)
  • Application successfully builds (npm run build)
  • The UI was verified against edge cases (loading, network errors, empty data) via tests.

Types of changes

  • Refactoring (non-breaking change that improves internal architecture)
  • [ X] Bug fix (non-breaking change which fixes an issue)
  • [ X] New feature (non-breaking change which adds functionality)
  • [ X] Breaking change (fix or feature that would cause existing functionality to change)

Closes #8

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

@jrcity is attempting to deploy a commit to the Prisca's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
octraban Ready Ready Preview, Comment Jul 29, 2026 8:58am

@priscaenoch
priscaenoch merged commit 37864f3 into octraban:main Jul 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate remaining raw fetch calls to React Query for consistent loading, error, and caching

2 participants