-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Problem Statement
When a collection is cleared using Onyx.clear() (e.g., clearing all report_ keys), useOnyx subscriptions to individual collection member keys (e.g., report_123) fail to recalculate and return the correct/newest value. The subscription value remains stale.
Expected Behaviour
After Onyx.clear() is called, all useOnyx hooks subscribed to collection member keys should be notified and re-render with the updated (cleared) values.
Actual Behavior
useOnyx works correctly with regular key subscriptions after Onyx.clear(), but not with collection member key subscriptions. The subscriber receives stale data instead of being properly notified of the change.
Root Cause Analysis
During Onyx.clear(), collection data is being notified through a different code path. Faulty logic is clearing the collection data from the cache before it can be used during the notify logic execution, which causes the useOnyx subscriber to not be properly notified of the change.
Reproduction
A failing unit test demonstrating this issue is available in:
- PR with failing test: [WIP] Fix useOnyx subscription to collection member key after Onyx.clear() react-native-onyx#722
Related
- Discovered in: Fix opening an expense report from Reports page shows the same report when open Inbox #79436
Issue Owner
Current Issue Owner: @fabioh8010Metadata
Metadata
Assignees
Labels
Type
Projects
Status