Refactor data hooks to follow React hook rules#41
Open
David-patrick-chuks wants to merge 2 commits into
Open
Conversation
Split factory-style feature hooks into direct use* query hooks with shared query key helpers, and update guild detail and access check screens to call them at render time. Closes Adamantine-guild#15
Lakes41
requested changes
Jun 24, 2026
Lakes41
left a comment
Contributor
There was a problem hiding this comment.
Good Job, Do resolve conflicts @David-patrick-chuks
Resolve conflicts by keeping the refactored useAccessCheckResult hook while integrating upstream QR scanner access-check flow and removing the legacy useAccessCheck module.
Contributor
|
@David-patrick-chuks Do resolve conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR refactors feature data hooks so
useQueryis called directly from conventional custom hooks instead of from functions returned by parent hooks. It splits the old factory-style hooks into smaller query hooks with shared query key helpers and updates the guild detail and access check screens to consume them at render time.Related Issue
Closes #15
Changes
🪝 Query Hook Refactor
[ADD]
src/lib/queryKeys.tsCentralized query key helpers for guild, membership, and access-check queries.
[ADD]
src/features/guilds/useGuild.tsAdded a direct
useGuild(guildId)hook and exportedcreateGuildQueryOptionsfor testability.[ADD]
src/features/guilds/useGuildConfig.tsAdded a direct
useGuildConfig(guildId)hook.[ADD]
src/features/guilds/useGuildRoles.tsAdded a direct
useGuildRoles(guildId)hook.[MODIFY]
src/features/membership/useMembership.tsReplaced the factory hook with a direct
useMembership(walletAddress, guildId)hook.[ADD]
src/features/membership/useUserRoles.tsAdded a direct
useUserRoles(walletAddress, guildId)hook.[ADD]
src/features/access/useAccessCheckResult.tsAdded a direct
useAccessCheckResult(params)hook for access-check queries.[DELETE]
src/features/guilds/useGuilds.tsRemoved the factory hook that returned
getGuild,getGuildConfig, andgetRoles.[DELETE]
src/features/access/useAccessCheck.tsRemoved the factory hook that returned
checkAccess.📱 Screen Updates
[MODIFY]
app/guilds/[guildId].tsxUpdated the guild detail screen to call
useGuild,useMembership, anduseGuildRolesdirectly at render time.[MODIFY]
app/access-check.tsxUpdated the access check screen to call
useAccessCheckResultdirectly at render time.[MODIFY]
app/guilds.tsxRemoved an unused membership hook import.
🧪 Tests
[ADD]
tests/hooks/useGuild.hook.test.tsAdded tests verifying the refactored hook calls
useQueryat the top level.Added tests for enabled guards, successful fetch, and error propagation.
[ADD]
tests/hooks/queryKeys.test.tsAdded tests for shared guild, membership, and access-check query key helpers.
Verification Results
[npx vitest run tests/hooks/useGuild.hook.test.ts tests/hooks/queryKeys.test.ts ✅ passed (9/9)]
use*conventionuseQueryis not called inside arbitrary callback functions