Summary
Refactor feature hooks so useQuery is called directly from custom hooks instead of from functions returned by hooks. This reduces the risk of rule-of-hooks violations and makes query behaviour easier to test.
Current Behaviour
Hooks such as useGuilds, useMembership, and useAccessCheck return functions like getGuild, getMembership, and checkAccess. Those functions call useQuery internally when invoked by screen components.
Expected Behaviour
Each query should be exposed as a conventional custom hook such as useGuild, useGuildRoles, useMembership, and useAccessCheckResult, with stable arguments and predictable enabled conditions.
Suggested Implementation
Split the current feature hooks into smaller query hooks. Move query key creation into shared helpers. Update screens to call the new hooks directly at component render time.
Files or Areas Likely Affected
src/features/guilds/useGuilds.ts
src/features/membership/useMembership.ts
src/features/access/useAccessCheck.ts
app/guilds/[guildId].tsx
app/access-check.tsx
Acceptance Criteria
Additional Notes
Assumption: current behaviour may work at runtime, but the current pattern makes hook ordering and linting harder to reason about.
Summary
Refactor feature hooks so
useQueryis called directly from custom hooks instead of from functions returned by hooks. This reduces the risk of rule-of-hooks violations and makes query behaviour easier to test.Current Behaviour
Hooks such as
useGuilds,useMembership, anduseAccessCheckreturn functions likegetGuild,getMembership, andcheckAccess. Those functions calluseQueryinternally when invoked by screen components.Expected Behaviour
Each query should be exposed as a conventional custom hook such as
useGuild,useGuildRoles,useMembership, anduseAccessCheckResult, with stable arguments and predictable enabled conditions.Suggested Implementation
Split the current feature hooks into smaller query hooks. Move query key creation into shared helpers. Update screens to call the new hooks directly at component render time.
Files or Areas Likely Affected
src/features/guilds/useGuilds.tssrc/features/membership/useMembership.tssrc/features/access/useAccessCheck.tsapp/guilds/[guildId].tsxapp/access-check.tsxAcceptance Criteria
use*conventionuseQueryis not called inside arbitrary callback functionsAdditional Notes
Assumption: current behaviour may work at runtime, but the current pattern makes hook ordering and linting harder to reason about.