-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
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 Owner
Current Issue Owner: @VickyStashMetadata
Metadata
Labels
Type
Projects
Status