Skip to content

useOnyx subscription to collection member key doesn't update correctly after Onyx.clear() #80105

@mountiny

Description

@mountiny

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:

Related

Issue OwnerCurrent Issue Owner: @fabioh8010

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2

Type

No type

Projects

Status

HIGH

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions