Skip to content

Conversation

@t0maboro
Copy link
Contributor

@t0maboro t0maboro commented Oct 6, 2025

Description

This PR adds support for synchronous updates in the native stack for React Native 0.82+. Currently, enabling synchronous state updates is possible via an experimental feature flag: unstable_synchronousStateUpdatesEnabled.

At this time, I haven't found a way to perform synchronous updates on Android, so this PR only includes mocks for that platform. I'm creating a ticket for covering that: https://github.com/software-mansion/react-native-screens-labs/issues/497

Fixes https://github.com/software-mansion/react-native-screens-labs/issues/495

Changes

  • Added feature flags in JS per native component for testing synchronous updates:
    • synchronousScreenUpdatesEnabled
    • synchronousHeaderConfigUpdatesEnabled
    • synchronousHeaderSubviewUpdatesEnabled
  • Added mocks for android implementation
  • Added implementation for all native components on iOS that are performing shadow tree state updates

Screenshots / GIFs

Before

before.mov

After

after.mov

Test code and steps to reproduce

Adding a new example, which is verifying that with synchronous updates enabled, the form sheet content flicker issues are resolved.

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

Base automatically changed from t0maboro/split-view-synchronous-updates to main October 6, 2025 13:23
@t0maboro t0maboro force-pushed the @t0maboro/native-stack-synchronous-updates branch from b794a54 to 3a71e96 Compare October 6, 2025 13:24
@t0maboro t0maboro marked this pull request as ready for review October 6, 2025 13:37
@t0maboro t0maboro changed the title Draft: add support for synchronous state updates on fabric for native stack feat(StackV4): Add support for synchronous state updates on fabric for native stack Oct 6, 2025
@t0maboro t0maboro changed the title feat(StackV4): Add support for synchronous state updates on fabric for native stack feat(Stack): Add support for synchronous state updates on fabric for native stack Oct 6, 2025
Copy link
Contributor

@kligarski kligarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@t0maboro t0maboro force-pushed the @t0maboro/native-stack-synchronous-updates branch from cafa658 to 0d6b842 Compare October 22, 2025 09:05
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few questions & suggestions. Please answer them.

Thank you for the PR.

@t0maboro t0maboro requested a review from kkafar October 24, 2025 09:57
@t0maboro t0maboro force-pushed the @t0maboro/native-stack-synchronous-updates branch from c4881f5 to 5f72498 Compare October 24, 2025 09:58
t0maboro added a commit that referenced this pull request Oct 24, 2025
…ync state update (#3285)

## Description

This code was originally added to mitigate issues with jumping content
during transitions. By observing the presentation layer, we were able to
send intermediate column size updates, which helped with making smoother
animation.

However, with the current ability to send immediate updates, it seems
that it now works well with the native SplitView transition. As a
result, we can remove the previously added logic, which was initially
introduced in:
#3073

How it appears to work now:
<img width="1033" height="151" alt="Screenshot 2025-10-07 at 12 50 03"
src="https://github.com/user-attachments/assets/fac535c0-60a5-42be-8a9d-3430dad418c3"
/>

How it appeared to work with DisplayLink:
<img width="1081" height="190" alt="Screenshot 2025-10-07 at 13 12 06"
src="https://github.com/user-attachments/assets/3704e0b5-bab4-4b35-b6e3-aafa77dfc01d"
/>

Having the final frame set immediately, we can rely on the native
animation (which implementation is a mystery for us). Still, it seems
that we're following the same path as natively, where I also observed
that the final frame is set at the beginning of the animation. This
model appears to work similarly to the Android version. For example,
when animating the keyboard, we can read the target value on animation
start
https://developer.android.com/develop/ui/views/layout/sw-keyboard#:~:text=onStart%20is%20called,the%20view%20properties.
It seems that setting intermediate frames, following the presentation
layer, might be slightly delayed for the value we read in comparison to
the value that is currently drawn.

Fixes
software-mansion/react-native-screens-labs#496

## Changes

- Removed logic related to observing presentation layer for sending
asynchronous state updates.

## Screenshots / GIFs

Here you can add screenshots / GIFs documenting your change.

You can add before / after section if you're changing some behavior.

### Before


https://github.com/user-attachments/assets/966d0b7f-665d-4add-947e-ceeddb81d0e2

### After


https://github.com/user-attachments/assets/69955aca-e9ae-48e2-a9fd-7d04ff65835f


## Test code and steps to reproduce

I went through SplitView examples, having synchronous updates in
SplitView and additionally sync updates for Stack v4
#3282 . I
focused on testing that there's no regression with pressables.

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I have on elast remark.

@t0maboro t0maboro requested a review from kkafar October 24, 2025 11:25
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, let's go

@t0maboro t0maboro merged commit ea2a033 into main Oct 24, 2025
9 checks passed
@t0maboro t0maboro deleted the @t0maboro/native-stack-synchronous-updates branch October 24, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants