Skip to content

Inconsistent style parsing and event ordering between iOS and Android #251

Description

@divineniiquaye

What happened?

I noticed a discrepancy in how styles are parsed and applied on iOS vs Android. The issue appears to originate in the UniwindStoreBuilder class, specifically within the getStyles method.

Expected behavior

The expected execution order during style resolution is:
1. Resolve styles
2. Subscribe to cache
3. Subscribe to re-render
4. Invoke Uniwind methods if present (updateCSSVariables, updateInsets, etc.)
5. Run subscribed events during the re-render
6. Complete
• Trigger additional re-renders if any Uniwind method notifies event dependencies

This flow works correctly on iOS.

Actual behavior on Android

On Android, events are fired before the re-render subscription is established. As a result, Uniwind methods that are expected to notify event dependencies (such as updateInsets) do not trigger the intended downstream updates.

In short:
• Event callbacks execute too early
• Re-render listeners are not yet subscribed
• Dependency notifications from Uniwind methods are missed

Steps to Reproduce

  • iOS follows the expected subscription and execution order
  • Android triggers events before re-render subscriptions are in place
  • This prevents Uniwind methods from correctly notifying event dependencies
  • The issue appears isolated to the execution order within getStyles

To reproduce:

  1. Log at src/core/native/store.ts#L38
  2. Log at src/components/native/useStyle.ts#L25
  3. Log at src/core/listener.ts#L43
  4. Log before you call eg. Uniwind.updateInsets

Snack or Repository Link

https://gist.github.com/divineniiquaye/cec774b3b6867769254ae75592b533c1

Uniwind version

1.2.2

React Native Version

0.81.5

Platforms

Android

Expo

Yes

Additional information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions