Skip to content

[Onyx Audit] Remove Outdated Batching Mechanism from Onyx #79338

@mountiny

Description

@mountiny

Coming from this proposal

Background

A lot of time ago the withOnyx HOC was the primary subscription mechanism in the Onyx.
To optimize performance, a custom batching system that uses unstable_batchedUpdates from React was implemented.
This batching logic collects multiple state updates to group subscriber notifications into a single React render cycle.

Over time, several things have happened:

  • The useOnyx hook, which is now the recommended pattern, was implemented. But custom batching logic wasn't adjusted to support the hook subscribers. It continued to work only for the withOnyx subscribers (more details here: [Onyx Audit] Batching mechanism feels overcomplicated Expensify/App#71207 (comment))
  • The withOnyx HOC has been deprecated in favor of the useOnyx hook.
  • React 18 introduced automatic batching for all updates (including those in promises, setTimeout, and native event handlers), which changes how state updates are batched in modern React applications.

Problem

When Onyx processes state updates in a codebase that no longer uses withOnyx, if legacy batching logic is still applied, then state update behaviour becomes harder to understand and maintain without providing clear benefits.

Solution

Remove the entire custom batching mechanism from Onyx and rely on React's native automatic batching capabilities.
Draft PR: Expensify/react-native-onyx#689

Issue OwnerCurrent Issue Owner: @VickyStash

Metadata

Metadata

Labels

AutoAssignerNewDotQualityUsed to assign quality issues to engineersBugSomething is broken. Auto assigns a BugZero manager.ReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

Status

HIGH

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions