Problem
When switching from Request tab back to Share tab, the component loses all state:
- GET link status shows as unlinked
- Donation status (
isActive) resets to false
- Shows 'Start Sharing' card instead of Impact card
- Account balances disappear
Root Cause
The Share tab component appears to be remounting when switching tabs, despite using NativeTabs which should keep components mounted. This may be a bug in:
- NativeTabs implementation in SDK 54
- Nested route groups
(share) and (request)
- Expo Router tab handling
Current Workaround
Added useFocusEffect hook that reloads all data when tab comes into focus:
- GET link status (
getGetLinkStatus)
- GET account balances (
getGetAccounts)
- Donation impact data (
getDonorImpact)
File: apps/mobile/app/(tabs)/(share)/index.tsx
Why It's Slow
Makes 3 API calls every time you switch tabs:
getGetLinkStatus(userId)
getGetAccounts(userId)
getDonorImpact(userId)
This is noticeable lag when switching tabs.
Ideal Solutions
Option 1: Fix Root Cause
Investigate why component is remounting and prevent it:
- Check NativeTabs behavior in SDK 54
- Test if upgrading to SDK 55 stable (when released) fixes it
- Try different tab layout configurations
Option 2: Cache State in Context
Move GET/donation state to a context provider (similar to TabCacheProvider) so it persists across remounts:
- Create
DonorStateProvider
- Store
isGetLinked, isActive, monthlyAmount, etc.
- Only make API calls on initial load and explicit refresh
Option 3: Throttle Refresh
Only refresh data if >30 seconds since last refresh, not on every tab switch.
Acceptance Criteria
References
Problem
When switching from Request tab back to Share tab, the component loses all state:
isActive) resets to falseRoot Cause
The Share tab component appears to be remounting when switching tabs, despite using NativeTabs which should keep components mounted. This may be a bug in:
(share)and(request)Current Workaround
Added
useFocusEffecthook that reloads all data when tab comes into focus:getGetLinkStatus)getGetAccounts)getDonorImpact)File:
apps/mobile/app/(tabs)/(share)/index.tsxWhy It's Slow
Makes 3 API calls every time you switch tabs:
getGetLinkStatus(userId)getGetAccounts(userId)getDonorImpact(userId)This is noticeable lag when switching tabs.
Ideal Solutions
Option 1: Fix Root Cause
Investigate why component is remounting and prevent it:
Option 2: Cache State in Context
Move GET/donation state to a context provider (similar to
TabCacheProvider) so it persists across remounts:DonorStateProviderisGetLinked,isActive,monthlyAmount, etc.Option 3: Throttle Refresh
Only refresh data if >30 seconds since last refresh, not on every tab switch.
Acceptance Criteria
References