Skip to content

refactor: drop unused useCallback / useMemo over-optimizations - #141

Open
Dustin-Kelley wants to merge 1 commit into
mainfrom
cursor/drop-unused-memoization-9089
Open

refactor: drop unused useCallback / useMemo over-optimizations#141
Dustin-Kelley wants to merge 1 commit into
mainfrom
cursor/drop-unused-memoization-9089

Conversation

@Dustin-Kelley

@Dustin-Kelley Dustin-Kelley commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Unwrap useCallback on native actions that only cross the Expo DOM bridge or unmemoized sheets
  • Drop a few matching useMemos (settings handlers, DOM verse-select catch wrapper, drain ensureFreshToken, sign-in logo size)
  • Leave context, effect-dep, public-hook, and NativeSheet backdrop memoization

Test plan

  • UI tests for BibleReader, BibleCard, VerseOfTheDay, picker sheets, settings sheet, sign-in sheet
  • Core drain-host test if present
  • Lint/typecheck on edited packages
Open in Web Open in Cursor 

Greptile Summary

This PR removes unnecessary React callback and value memoization while preserving the existing action, bridge, sheet, settings, sharing, and highlight-drain behavior.

  • Replaces memoized native and DOM event handlers with render-local functions.
  • Creates the static YouVersion wordmark dimensions once at module scope.
  • Keeps highlight authentication state current through the existing ref-based drain contract.

Confidence Score: 5/5

The PR appears safe to merge because the removed memoization does not participate in any established identity-sensitive contract.

The changed functions retain the same inputs, closures, side effects, platform guards, and error handling, while the investigated drain and immediate UI consumers do not use their identities to control lifecycle behavior.

Important Files Changed

Filename Overview
packages/core/src/highlights/highlight-queue-drain-host.tsx Recreates the token-refresh wrapper per render; the drain reads it through a ref and does not depend on its identity.
packages/ui/src/dom/bible-reader.tsx Removes memoization from the verse-selection rejection wrapper without changing its error handling or bridge-facing behavior.
packages/ui/src/native/bible-reader.tsx Unwraps numerous action handlers while preserving their state, authentication, selection, copy, share, picker, and external-link logic.
packages/ui/src/native/bible-reader-settings-sheet.tsx Creates settings handlers during render while retaining fresh store getters and the same setter wiring.
packages/ui/src/native/bible-card.tsx Removes callback memoization from version-picker and footnote actions without altering platform guards or consumer override behavior.
packages/ui/src/native/bible-chapter-picker-sheet.tsx Makes the keyboard-dismiss handler render-local while retaining nonce-based dismissal behavior.
packages/ui/src/native/bible-version-picker-sheet.tsx Makes the keyboard-dismiss handler render-local while preserving picker reset and open-state behavior.
packages/ui/src/native/sign-in-with-youversion-sheet.tsx Hoists deterministic logo dimensions to module scope without changing rendered sizing or localized accessibility copy.
packages/ui/src/native/verse-of-the-day.tsx Removes callback memoization from sharing while preserving consumer overrides, native fallback sharing, and error handling.

Reviews (1): Last reviewed commit: "refactor: drop unused useCallback / useM..." | Re-trigger Greptile

Expo DOM looks up native handlers by name at call time, so wrapping
handlers only to cross the DOM bridge or an unmemoized sheet has no
Object.is customer. Keep wraps that feed context, effect deps, public
hooks, or Gorhom renderBackdrop.

Co-authored-by: Dustin Kelley <Dustin-Kelley@users.noreply.github.com>
@Dustin-Kelley
Dustin-Kelley force-pushed the cursor/drop-unused-memoization-9089 branch from a79f980 to e00917c Compare August 19, 2026 16:13
@Dustin-Kelley
Dustin-Kelley changed the base branch from dk/pass-highlights-into-votd-biblecard to main August 19, 2026 16:13
@cameronapak

Copy link
Copy Markdown
Collaborator

Excited about this one lol

@Dustin-Kelley
Dustin-Kelley marked this pull request as ready for review August 19, 2026 21:21
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