Overview
src/components/mobile/SettingRow.tsx receives an onPress or right render prop that is defined as an inline arrow function in the parent settings screen. Because the parent re-renders on any store state change (theme, user, network), a new function reference is created each time. SettingRow is a pure component (React.memo) but the unstable onPress reference defeats the memo check and causes unnecessary re-renders for every row in the settings list.
Specifications
Features:
- All
onPress handlers in settings screens wrapped with useCallback
SettingRow props are stable across parent re-renders that don't change setting values
- Re-render confirmed absent on unrelated store changes via Profiler
Tasks:
- Audit the parent settings screen(s) for inline
onPress functions
- Wrap each with
useCallback with correct dependency array
- Verify
SettingRow has React.memo wrapping
- Add profiler test confirming
SettingRow does not re-render on unrelated parent state change
Impacted Files:
- Settings screen component(s) in
src/pages/mobile/ or src/components/mobile/
src/components/mobile/SettingRow.tsx
Acceptance Criteria
onPress handler reference is stable across parent re-renders
SettingRow does not re-render when unrelated store state changes
- Profiler confirms 0 re-renders for settings rows on theme toggle
- All
useCallback dependency arrays are correct (no missing deps)
Overview
src/components/mobile/SettingRow.tsxreceives anonPressorrightrender prop that is defined as an inline arrow function in the parent settings screen. Because the parent re-renders on any store state change (theme, user, network), a new function reference is created each time.SettingRowis a pure component (React.memo) but the unstableonPressreference defeats the memo check and causes unnecessary re-renders for every row in the settings list.Specifications
Features:
onPresshandlers in settings screens wrapped withuseCallbackSettingRowprops are stable across parent re-renders that don't change setting valuesTasks:
onPressfunctionsuseCallbackwith correct dependency arraySettingRowhasReact.memowrappingSettingRowdoes not re-render on unrelated parent state changeImpacted Files:
src/pages/mobile/orsrc/components/mobile/src/components/mobile/SettingRow.tsxAcceptance Criteria
onPresshandler reference is stable across parent re-rendersSettingRowdoes not re-render when unrelated store state changesuseCallbackdependency arrays are correct (no missing deps)