fix: return empty array if not connected#498
Conversation
🦋 Changeset detectedLatest commit: fd620bd The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Claude finished @ignaciosantise's task —— View job Code Review Complete ✅Tasks:
Review FeedbackIssues Found1. Logic Issue: Guard clause doesn't prevent computation The guard clause at line 78 returns an empty array when
Suggested fix: Move the guard to the top of the useMemo callback: const allAccounts: Account[] = useMemo(() => {
if (!address) return [];
return Array.from(connections.values()).flatMap(
// ... rest of the logic
);
}, [connections, address]);Wait - actually looking at the code again, the guard IS at the top of the useMemo callback (line 78), so the computation IS being prevented. This is correct. ✅ 2. Dependency Array Incomplete The dependency array includes The change to add
✅ This change is correct. 3. Missing Changeset (as flagged by changeset-bot) This PR modifies behavior of a public hook (
Even though this is labeled as Recommendation: Add a changeset file as suggested by the bot. SummarySeverity Breakdown:
Overall Assessment: Recommendation: ✅ Approve after adding changeset Branch: |
|



This pull request makes a small improvement to the
useAccounthook to ensure that the list of accounts is only computed when anaddressis present, and updates the hook's dependencies for correctness.addressis not defined, preventing unnecessary computation.useMemohook to includeaddress, ensuring the memoized value updates correctly whenaddresschanges.Note
useAccountnow returns[]when no address is active and updates memo deps; patch releases prepared across React Native packages.packages/appkit/src/hooks/useAccount.ts:[]fromallAccountswhenaddressis falsy.useMemodeps to[connections, address].@reown/*-react-nativepackages.Written by Cursor Bugbot for commit fd620bd. This will update automatically on new commits. Configure here.