Skip to content

Primarily refines dependency arrays in React hooks to prevent unnecessary re-renders and refetch loops ➿#562

Merged
jamespepper81 merged 5 commits into
mainfrom
dev
Feb 23, 2026
Merged

Primarily refines dependency arrays in React hooks to prevent unnecessary re-renders and refetch loops ➿#562
jamespepper81 merged 5 commits into
mainfrom
dev

Conversation

@jamespepper81
Copy link
Copy Markdown
Contributor

This pull request primarily refines dependency arrays in React hooks to prevent unnecessary re-renders and refetch loops. It also includes a minor type improvement and removes an unused property. These changes help optimize performance and clarify intent in the codebase.

React hook dependency optimizations:

  • app/(tabs)/receive.tsx: Added a comment explaining why certain dependencies (walletService and stable setters/callbacks) are intentionally omitted from the useEffect dependency array to avoid unnecessary refetch loops.
  • components/AnimatedNumber.tsx: Removed stable shared value refs (animatedValue, scale) from useEffect dependency arrays, with comments clarifying their omission and ESLint disables for clarity. [1] [2]

Codebase cleanup:

Type improvement:

  • app/wallet-setup.tsx: Changed the type annotation for requiredFunctions to use Array<keyof WalletService> for clarity and consistency.

jamespepper81 and others added 5 commits February 23, 2026 17:54
Add comment to clarify dependency omission in useEffect.
…and invalid defaultValue prop

Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com>
…ependencies

fix(AnimatedNumber): remove stable shared value refs from dep arrays and invalid defaultValue prop
Copilot AI review requested due to automatic review settings February 23, 2026 18:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines React hook dependency arrays to reduce unnecessary effect re-runs/refetch loops, with a small TypeScript type annotation tweak and a minor cleanup in an animation component.

Changes:

  • Adjusts hook dependency arrays and adds rationale comments / eslint disables where deps are intentionally omitted.
  • Cleans up AnimatedNumber derived value return shape by removing an unused property.
  • Tweaks a WalletService-key array type annotation for clarity.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
components/AnimatedNumber.tsx Updates useEffect deps / eslint disables for shared values; removes defaultValue from derived return object.
app/wallet-setup.tsx Changes requiredFunctions type annotation to Array<keyof WalletService>.
app/(tabs)/receive.tsx Adds an inline comment clarifying why certain deps are intentionally omitted for a useEffect.
Comments suppressed due to low confidence (2)

components/AnimatedNumber.tsx:40

  • These effects now rely on an eslint-disable for exhaustive-deps solely to omit animatedValue. Since useSharedValue returns a stable ref, keeping animatedValue in the dependency array won’t cause re-runs but does avoid suppressing the lint rule. Consider re-adding animatedValue to the deps and removing the eslint-disable here to reduce lint suppressions.
  useEffect(() => {
    animatedValue.value = withTiming(value, { duration });
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [value, duration]); // animatedValue is a stable shared value ref and should not be in deps

components/AnimatedNumber.tsx:50

  • Same as above: omitting the stable scale shared value forces an eslint-disable. Including scale in the dependency array should be harmless (stable ref) and lets you remove the exhaustive-deps suppression.
  useEffect(() => {
    scale.value = withSpring(1.02, { damping: 8, stiffness: 300 }, () => {
      scale.value = withSpring(1, { damping: 15, stiffness: 400 });
    });
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [value]); // scale is a stable shared value ref and should not be in deps

@jamespepper81 jamespepper81 merged commit 64bcba1 into main Feb 23, 2026
16 of 17 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.

3 participants