Skip to content

refactor(frontend): Extract useAsyncPageData hook for shared page state scaffolding (#1085) - #1142

Open
abdulqoyumadegoke wants to merge 3 commits into
LabsCrypt:mainfrom
abdulqoyumadegoke:refactor/1085-shared-async-page-data-hook
Open

refactor(frontend): Extract useAsyncPageData hook for shared page state scaffolding (#1085)#1142
abdulqoyumadegoke wants to merge 3 commits into
LabsCrypt:mainfrom
abdulqoyumadegoke:refactor/1085-shared-async-page-data-hook

Conversation

@abdulqoyumadegoke

Copy link
Copy Markdown
Contributor

Closes #1085

Overview

Resolves #1085 by extracting a shared useAsyncPageData hook in frontend/src/hooks/useAsyncPageData.ts and refactoring activity-content.tsx and incoming-content.tsx to use it for unified loading, error, hydration, wallet connection, and empty state scaffolding.

Key Changes

  • frontend/src/hooks/useAsyncPageData.ts: Created a reusable custom hook encapsulating useWallet hydration and connection status, query loading states, error message normalization, and empty list detection.
  • useAsyncPageData.test.ts: Added unit tests covering hydration, wallet status, loading, error string extraction, and empty data scenarios.
  • activity-content.tsx & incoming-content.tsx: Migrated page components to consume useAsyncPageData state properties.

Verification

  • Verified unit tests for useAsyncPageData and existing page components.

@ogazboiz ogazboiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the hook extraction is good, both the activity and incoming pages genuinely dedupe onto it and the behavior mapping is preserved exactly (I checked the !isHydrated || (connected && loading) equivalence). one blocker now that main is green: your new hook test file fails lint with 5 no-explicit-any errors (lines 22:10, 37:10, 51:10, 67:10, 83:10). type those mocks properly (or use unknown with narrowing), run npm run lint locally, and this merges. if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

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.

[Frontend] activity-content.tsx and incoming-content.tsx duplicate the same fetch/loading/error scaffolding with no shared hook

2 participants