fix(ui): skip per-frame re-renders on the swatch tray - #133
Conversation
Scroll offset stays in a ref; React only stores the fade-gate booleans so a drag does not rebuild the verse action sheet every frame. Co-authored-by: Cursor <cursoragent@cursor.com>
bmanquen
left a comment
There was a problem hiding this comment.
Two-axis review (Standards + Spec) against HEAD~1.
Standards: no hard violations. ADR 0017's load-bearing decisions are all intact — the fade still gates on remaining scroll distance, modal={false} and PAN_ACTIVE_OFFSET_Y are untouched, the sheet stays internal, and the explanatory comment block was preserved rather than dropped. No new user-visible strings, so .greptile/rules.md / native-i18n.md don't bite, and .changeset/native-highlights-release.md already covers the sheet.
Spec: not run — no issue reference in the commit, no spec file matching the branch.
Six judgement calls inline, all non-blocking. The one worth acting on is the first: swatchTrayFadeGates is a pure predicate sitting in the component, which is why its only coverage has to boot the whole BibleReader.
Move the remaining-distance predicate to layer 1 so the arithmetic can be tested without booting BibleReader, and store tray metrics as one ref. Co-authored-by: Cameron Pak <cameronandrewpak@gmail.com>
Summary
Swatch-tray fades still appear and retire at the same remaining-distance gates, but a drag no longer re-renders the verse action sheet every frame.
Changes
Test plan
pnpm --filter @youversion/platform-react-native-expo-ui test -- src/native/__tests__/bible-reader-verse-actions.test.tsx(27 passed)npx react-doctor@latest --scope changed—rn-no-scroll-stateis goneMade with Cursor
Greptile Summary
The PR extracts swatch-tray fade arithmetic into a tested helper and stores live measurements in refs so scrolling updates React only when an edge-visibility gate changes.
Confidence Score: 5/5 ·
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Reviews (2): Last reviewed commit: "refactor(ui): extract swatch tray fade g..." | Re-trigger Greptile