diff --git a/packages/jest-preset/jest/mocks/RendererProxy.js b/packages/jest-preset/jest/mocks/RendererProxy.js index ffc599f08e01..3ae7324d9b78 100644 --- a/packages/jest-preset/jest/mocks/RendererProxy.js +++ b/packages/jest-preset/jest/mocks/RendererProxy.js @@ -17,6 +17,7 @@ const { dispatchCommand, findHostInstance_DEPRECATED, findNodeHandle, + flushSync, getNodeFromInternalInstanceHandle, getPublicInstanceFromInternalInstanceHandle, getPublicInstanceFromRootTag, @@ -32,6 +33,7 @@ export { dispatchCommand, findHostInstance_DEPRECATED, findNodeHandle, + flushSync, getNodeFromInternalInstanceHandle, getPublicInstanceFromInternalInstanceHandle, getPublicInstanceFromRootTag, diff --git a/packages/react-native/Libraries/ReactNative/RendererImplementation.js b/packages/react-native/Libraries/ReactNative/RendererImplementation.js index 936c268d29f5..d0fdede1b2db 100644 --- a/packages/react-native/Libraries/ReactNative/RendererImplementation.js +++ b/packages/react-native/Libraries/ReactNative/RendererImplementation.js @@ -50,6 +50,7 @@ export const findNodeHandle: { componentOrHandle: ?(React.ElementRef | number), ): ?number, }['findNodeHandle'] = ReactFabric.findNodeHandle; +export const flushSync = ReactFabric.flushSync; export const sendAccessibilityEvent = ReactFabric.sendAccessibilityEvent; export const isChildPublicInstance = ReactFabric.isChildPublicInstance; export const getNodeFromInternalInstanceHandle = diff --git a/packages/react-native/Libraries/ReactNative/__tests__/flushSync-itest.js b/packages/react-native/Libraries/ReactNative/__tests__/flushSync-itest.js new file mode 100644 index 000000000000..83bf5d334014 --- /dev/null +++ b/packages/react-native/Libraries/ReactNative/__tests__/flushSync-itest.js @@ -0,0 +1,194 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @fantom_flags enableFlushSync:* + * @flow strict-local + * @format + */ + +import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; + +import type {HostInstance} from 'react-native'; + +import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags'; +import * as Fantom from '@react-native/fantom'; +import nullthrows from 'nullthrows'; +import * as React from 'react'; +import {createRef, startTransition, useLayoutEffect, useState} from 'react'; +import {View, unstable_flushSync as maybeFlushSync} from 'react-native'; + +let log: Array = []; +let setN: (n: number) => void = () => {}; +const counterRef = createRef(); + +type CounterProps = {onPointerUp?: () => void}; + +function Counter({onPointerUp}: CounterProps): React.Node { + const [n, _setN] = useState(0); + setN = _setN; + log.push(`render:${n}`); + useLayoutEffect(() => { + log.push(`layout:${n}`); + }, [n]); + return ; +} + +function renderCounter(props?: CounterProps): Fantom.Root { + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(); + }); + expect(log).toEqual(['render:0', 'layout:0']); + log = []; + return root; +} + +beforeEach(() => { + log = []; +}); + +(ReactNativeFeatureFlags.enableFlushSync() ? it.skip : it)( + 'is not exported when enableFlushSync is disabled', + () => { + expect(maybeFlushSync).toBe(undefined); + }, +); + +(ReactNativeFeatureFlags.enableFlushSync() ? describe : describe.skip)( + 'flushSync', + () => { + let flushSync: NonNullable; + + beforeEach(() => { + flushSync = nullthrows(maybeFlushSync); + }); + + it('is exported from react-native', () => { + expect(typeof maybeFlushSync).toBe('function'); + }); + + it('flushes updates synchronously before returning', () => { + renderCounter(); + + Fantom.runTask(() => { + flushSync(() => setN(1)); + log.push('after'); + }); + + expect(log).toEqual(['render:1', 'layout:1', 'after']); + }); + + it('without flushSync, updates are deferred', () => { + renderCounter(); + + Fantom.runTask(() => { + setN(1); + log.push('after'); + }); + + expect(log).toEqual(['after', 'render:1', 'layout:1']); + }); + + it('opts out of transitions', () => { + renderCounter(); + + Fantom.runTask(() => { + startTransition(() => { + flushSync(() => setN(1)); + log.push('after'); + }); + }); + + expect(log).toEqual(['render:1', 'layout:1', 'after']); + }); + + it("returns the callback's return value", () => { + expect(flushSync(() => 42)).toBe(42); + expect(flushSync()).toBe(undefined); + }); + + it('propagates errors from the callback and still flushes updates', () => { + renderCounter(); + + Fantom.runTask(() => { + expect(() => + flushSync(() => { + setN(1); + throw new Error('boom'); + }), + ).toThrow('boom'); + log.push('after'); + }); + + expect(log).toEqual(['render:1', 'layout:1', 'after']); + }); + + it('flushes pending sync work when called without a callback', () => { + renderCounter({ + onPointerUp: () => { + setN(1); + flushSync(); + log.push('after'); + }, + }); + + Fantom.dispatchNativeEvent( + nullthrows(counterRef.current), + 'onPointerUp', + {x: 0, y: 0}, + {category: Fantom.NativeEventCategory.Discrete}, + ); + + expect(log).toEqual(['render:1', 'layout:1', 'after']); + }); + + it('warns and defers the update when called during commit', () => { + const originalConsoleError = console.error; + const consoleErrorSpy = jest.fn(); + // $FlowFixMe[cannot-write] + console.error = consoleErrorSpy; + try { + let didFlush = false; + function App(): React.Node { + useLayoutEffect(() => { + if (!didFlush) { + didFlush = true; + flushSync(() => setN(1)); + log.push('after'); + } + }); + return ; + } + + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(); + }); + + expect(log).toEqual([ + 'render:0', + 'layout:0', + 'after', + 'render:1', + 'layout:1', + ]); + if (__DEV__) { + expect(consoleErrorSpy).toHaveBeenCalledTimes(1); + expect(consoleErrorSpy.mock.calls[0][0]).toBe( + 'flushSync was called from inside a lifecycle method. React ' + + 'cannot flush when React is already rendering. Consider moving ' + + 'this call to a scheduler task or micro task.', + ); + } else { + expect(consoleErrorSpy).not.toHaveBeenCalled(); + } + } finally { + // $FlowFixMe[cannot-write] + console.error = originalConsoleError; + } + }); + }, +); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt index 24277871afb6..4235f29476be 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<9a675a67a9ce5e7ca443dd319e2af91a>> + * @generated SignedSource<<3a6a61e2cc2bf01a35ab5c3919462ad5>> */ /** @@ -198,6 +198,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun enableFlexboxAutoMinSizeInStrictMode(): Boolean = accessor.enableFlexboxAutoMinSizeInStrictMode() + /** + * Exposes `unstable_flushSync` from the `react-native` package, with the same semantics as `flushSync` from `react-dom`. + */ + @JvmStatic + public fun enableFlushSync(): Boolean = accessor.enableFlushSync() + /** * When mount items are queued while MountItemDispatcher is already dispatching on Android (e.g. from a synchronous state update), dispatch them in the same frame instead of deferring them to the next one. */ diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt index 7c30f96a71bf..1369551650b4 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<6b668cbb1ef60126d7e08b2d853b1262>> + * @generated SignedSource<> */ /** @@ -48,6 +48,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces private var enableFabricCommitBranchingMergeOnMainThreadCache: Boolean? = null private var enableFabricLogsCache: Boolean? = null private var enableFlexboxAutoMinSizeInStrictModeCache: Boolean? = null + private var enableFlushSyncCache: Boolean? = null private var enableFollowUpMountItemDispatchAndroidCache: Boolean? = null private var enableIOSCompressedTextFrameAdjustmentCache: Boolean? = null private var enableIOSTextBaselineOffsetPerLineCache: Boolean? = null @@ -376,6 +377,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun enableFlushSync(): Boolean { + var cached = enableFlushSyncCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.enableFlushSync() + enableFlushSyncCache = cached + } + return cached + } + override fun enableFollowUpMountItemDispatchAndroid(): Boolean { var cached = enableFollowUpMountItemDispatchAndroidCache if (cached == null) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt index 03bba689ab05..605434477a73 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<0890a0b7979d00172b0a79abd94f6c3e>> + * @generated SignedSource<> */ /** @@ -84,6 +84,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun enableFlexboxAutoMinSizeInStrictMode(): Boolean + @DoNotStrip @JvmStatic public external fun enableFlushSync(): Boolean + @DoNotStrip @JvmStatic public external fun enableFollowUpMountItemDispatchAndroid(): Boolean @DoNotStrip @JvmStatic public external fun enableIOSCompressedTextFrameAdjustment(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt index 73e4a521e946..536ffc40b810 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3ca183dbeeb3fdeac98780267df9dff2>> + * @generated SignedSource<<834b0e9533cbc775a1c12b86140d718d>> */ /** @@ -79,6 +79,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun enableFlexboxAutoMinSizeInStrictMode(): Boolean = false + override fun enableFlushSync(): Boolean = false + override fun enableFollowUpMountItemDispatchAndroid(): Boolean = false override fun enableIOSCompressedTextFrameAdjustment(): Boolean = false diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt index 9dd027c0ffe9..b03e57fa3d90 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<15c65d4497fd9f36f8902efb2812b3b2>> */ /** @@ -52,6 +52,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc private var enableFabricCommitBranchingMergeOnMainThreadCache: Boolean? = null private var enableFabricLogsCache: Boolean? = null private var enableFlexboxAutoMinSizeInStrictModeCache: Boolean? = null + private var enableFlushSyncCache: Boolean? = null private var enableFollowUpMountItemDispatchAndroidCache: Boolean? = null private var enableIOSCompressedTextFrameAdjustmentCache: Boolean? = null private var enableIOSTextBaselineOffsetPerLineCache: Boolean? = null @@ -408,6 +409,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc return cached } + override fun enableFlushSync(): Boolean { + var cached = enableFlushSyncCache + if (cached == null) { + cached = currentProvider.enableFlushSync() + accessedFeatureFlags.add("enableFlushSync") + enableFlushSyncCache = cached + } + return cached + } + override fun enableFollowUpMountItemDispatchAndroid(): Boolean { var cached = enableFollowUpMountItemDispatchAndroidCache if (cached == null) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt index 70cde8f01bef..8e45070b5b8e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<8d21b1b7d2bd5c5fe3a111c0d411f742>> + * @generated SignedSource<<89f683cb28a7d1ef52c86faa96f1107c>> */ /** @@ -79,6 +79,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun enableFlexboxAutoMinSizeInStrictMode(): Boolean + @DoNotStrip public fun enableFlushSync(): Boolean + @DoNotStrip public fun enableFollowUpMountItemDispatchAndroid(): Boolean @DoNotStrip public fun enableIOSCompressedTextFrameAdjustment(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp index f1eff8d3e833..05171db79951 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<407c8e5915db07bb6cc2b9ba4449750a>> */ /** @@ -207,6 +207,12 @@ class ReactNativeFeatureFlagsJavaProvider return method(javaProvider_); } + bool enableFlushSync() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableFlushSync"); + return method(javaProvider_); + } + bool enableFollowUpMountItemDispatchAndroid() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableFollowUpMountItemDispatchAndroid"); @@ -801,6 +807,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableFlexboxAutoMinSizeInStrictMode( return ReactNativeFeatureFlags::enableFlexboxAutoMinSizeInStrictMode(); } +bool JReactNativeFeatureFlagsCxxInterop::enableFlushSync( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::enableFlushSync(); +} + bool JReactNativeFeatureFlagsCxxInterop::enableFollowUpMountItemDispatchAndroid( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::enableFollowUpMountItemDispatchAndroid(); @@ -1291,6 +1302,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "enableFlexboxAutoMinSizeInStrictMode", JReactNativeFeatureFlagsCxxInterop::enableFlexboxAutoMinSizeInStrictMode), + makeNativeMethod( + "enableFlushSync", + JReactNativeFeatureFlagsCxxInterop::enableFlushSync), makeNativeMethod( "enableFollowUpMountItemDispatchAndroid", JReactNativeFeatureFlagsCxxInterop::enableFollowUpMountItemDispatchAndroid), diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h index aecc722b136d..8a3d8c458db7 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<7cb5d49e9124d56b3e242e2023db8649>> */ /** @@ -114,6 +114,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool enableFlexboxAutoMinSizeInStrictMode( facebook::jni::alias_ref); + static bool enableFlushSync( + facebook::jni::alias_ref); + static bool enableFollowUpMountItemDispatchAndroid( facebook::jni::alias_ref); diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp index 74d72ae7e94c..8b4970ef87f2 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<44185d291de75775e5b1b41fc6aacb8c>> + * @generated SignedSource<> */ /** @@ -138,6 +138,10 @@ bool ReactNativeFeatureFlags::enableFlexboxAutoMinSizeInStrictMode() { return getAccessor().enableFlexboxAutoMinSizeInStrictMode(); } +bool ReactNativeFeatureFlags::enableFlushSync() { + return getAccessor().enableFlushSync(); +} + bool ReactNativeFeatureFlags::enableFollowUpMountItemDispatchAndroid() { return getAccessor().enableFollowUpMountItemDispatchAndroid(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index 519b5daa808a..dd6d63f73738 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<399726570a1c326455da3a015add1d9b>> + * @generated SignedSource<<2ddd9296377ea4c1fd9c84883fbde049>> */ /** @@ -181,6 +181,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool enableFlexboxAutoMinSizeInStrictMode(); + /** + * Exposes `unstable_flushSync` from the `react-native` package, with the same semantics as `flushSync` from `react-dom`. + */ + RN_EXPORT static bool enableFlushSync(); + /** * When mount items are queued while MountItemDispatcher is already dispatching on Android (e.g. from a synchronous state update), dispatch them in the same frame instead of deferring them to the next one. */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index ad5cbd622ecf..461adbb5f517 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<13736d698e7f80d874ef56c0b592470d>> + * @generated SignedSource<> */ /** @@ -533,6 +533,24 @@ bool ReactNativeFeatureFlagsAccessor::enableFlexboxAutoMinSizeInStrictMode() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::enableFlushSync() { + auto flagValue = enableFlushSync_.load(); + + if (!flagValue.has_value()) { + // This block is not exclusive but it is not necessary. + // If multiple threads try to initialize the feature flag, we would only + // be accessing the provider multiple times but the end state of this + // instance and the returned flag value would be the same. + + markFlagAsAccessed(28, "enableFlushSync"); + + flagValue = currentProvider_->enableFlushSync(); + enableFlushSync_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::enableFollowUpMountItemDispatchAndroid() { auto flagValue = enableFollowUpMountItemDispatchAndroid_.load(); @@ -542,7 +560,7 @@ bool ReactNativeFeatureFlagsAccessor::enableFollowUpMountItemDispatchAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(28, "enableFollowUpMountItemDispatchAndroid"); + markFlagAsAccessed(29, "enableFollowUpMountItemDispatchAndroid"); flagValue = currentProvider_->enableFollowUpMountItemDispatchAndroid(); enableFollowUpMountItemDispatchAndroid_ = flagValue; @@ -560,7 +578,7 @@ bool ReactNativeFeatureFlagsAccessor::enableIOSCompressedTextFrameAdjustment() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(29, "enableIOSCompressedTextFrameAdjustment"); + markFlagAsAccessed(30, "enableIOSCompressedTextFrameAdjustment"); flagValue = currentProvider_->enableIOSCompressedTextFrameAdjustment(); enableIOSCompressedTextFrameAdjustment_ = flagValue; @@ -578,7 +596,7 @@ bool ReactNativeFeatureFlagsAccessor::enableIOSTextBaselineOffsetPerLine() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(30, "enableIOSTextBaselineOffsetPerLine"); + markFlagAsAccessed(31, "enableIOSTextBaselineOffsetPerLine"); flagValue = currentProvider_->enableIOSTextBaselineOffsetPerLine(); enableIOSTextBaselineOffsetPerLine_ = flagValue; @@ -596,7 +614,7 @@ bool ReactNativeFeatureFlagsAccessor::enableIOSViewClipToPaddingBox() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(31, "enableIOSViewClipToPaddingBox"); + markFlagAsAccessed(32, "enableIOSViewClipToPaddingBox"); flagValue = currentProvider_->enableIOSViewClipToPaddingBox(); enableIOSViewClipToPaddingBox_ = flagValue; @@ -614,7 +632,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImagePrefetchingAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(32, "enableImagePrefetchingAndroid"); + markFlagAsAccessed(33, "enableImagePrefetchingAndroid"); flagValue = currentProvider_->enableImagePrefetchingAndroid(); enableImagePrefetchingAndroid_ = flagValue; @@ -632,7 +650,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImageTransparentTintColor() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(33, "enableImageTransparentTintColor"); + markFlagAsAccessed(34, "enableImageTransparentTintColor"); flagValue = currentProvider_->enableImageTransparentTintColor(); enableImageTransparentTintColor_ = flagValue; @@ -650,7 +668,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImmediateUpdateModeForContentOffsetC // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(34, "enableImmediateUpdateModeForContentOffsetChanges"); + markFlagAsAccessed(35, "enableImmediateUpdateModeForContentOffsetChanges"); flagValue = currentProvider_->enableImmediateUpdateModeForContentOffsetChanges(); enableImmediateUpdateModeForContentOffsetChanges_ = flagValue; @@ -668,7 +686,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImmediateUpdateModeForScrollContentV // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(35, "enableImmediateUpdateModeForScrollContentView"); + markFlagAsAccessed(36, "enableImmediateUpdateModeForScrollContentView"); flagValue = currentProvider_->enableImmediateUpdateModeForScrollContentView(); enableImmediateUpdateModeForScrollContentView_ = flagValue; @@ -686,7 +704,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImperativeEvents() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(36, "enableImperativeEvents"); + markFlagAsAccessed(37, "enableImperativeEvents"); flagValue = currentProvider_->enableImperativeEvents(); enableImperativeEvents_ = flagValue; @@ -704,7 +722,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImperativeFocus() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(37, "enableImperativeFocus"); + markFlagAsAccessed(38, "enableImperativeFocus"); flagValue = currentProvider_->enableImperativeFocus(); enableImperativeFocus_ = flagValue; @@ -722,7 +740,7 @@ bool ReactNativeFeatureFlagsAccessor::enableInteractableResponderViews() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(38, "enableInteractableResponderViews"); + markFlagAsAccessed(39, "enableInteractableResponderViews"); flagValue = currentProvider_->enableInteractableResponderViews(); enableInteractableResponderViews_ = flagValue; @@ -740,7 +758,7 @@ bool ReactNativeFeatureFlagsAccessor::enableInteractiveInlineButtons() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(39, "enableInteractiveInlineButtons"); + markFlagAsAccessed(40, "enableInteractiveInlineButtons"); flagValue = currentProvider_->enableInteractiveInlineButtons(); enableInteractiveInlineButtons_ = flagValue; @@ -758,7 +776,7 @@ bool ReactNativeFeatureFlagsAccessor::enableInteropViewManagerClassLookUpOptimiz // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(40, "enableInteropViewManagerClassLookUpOptimizationIOS"); + markFlagAsAccessed(41, "enableInteropViewManagerClassLookUpOptimizationIOS"); flagValue = currentProvider_->enableInteropViewManagerClassLookUpOptimizationIOS(); enableInteropViewManagerClassLookUpOptimizationIOS_ = flagValue; @@ -776,7 +794,7 @@ bool ReactNativeFeatureFlagsAccessor::enableIntersectionObserverByDefault() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(41, "enableIntersectionObserverByDefault"); + markFlagAsAccessed(42, "enableIntersectionObserverByDefault"); flagValue = currentProvider_->enableIntersectionObserverByDefault(); enableIntersectionObserverByDefault_ = flagValue; @@ -794,7 +812,7 @@ bool ReactNativeFeatureFlagsAccessor::enableKeyEvents() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(42, "enableKeyEvents"); + markFlagAsAccessed(43, "enableKeyEvents"); flagValue = currentProvider_->enableKeyEvents(); enableKeyEvents_ = flagValue; @@ -812,7 +830,7 @@ bool ReactNativeFeatureFlagsAccessor::enableLayoutAnimationsOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(43, "enableLayoutAnimationsOnAndroid"); + markFlagAsAccessed(44, "enableLayoutAnimationsOnAndroid"); flagValue = currentProvider_->enableLayoutAnimationsOnAndroid(); enableLayoutAnimationsOnAndroid_ = flagValue; @@ -830,7 +848,7 @@ bool ReactNativeFeatureFlagsAccessor::enableLayoutAnimationsOnIOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(44, "enableLayoutAnimationsOnIOS"); + markFlagAsAccessed(45, "enableLayoutAnimationsOnIOS"); flagValue = currentProvider_->enableLayoutAnimationsOnIOS(); enableLayoutAnimationsOnIOS_ = flagValue; @@ -848,7 +866,7 @@ bool ReactNativeFeatureFlagsAccessor::enableModuleArgumentNSNullConversionIOS() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(45, "enableModuleArgumentNSNullConversionIOS"); + markFlagAsAccessed(46, "enableModuleArgumentNSNullConversionIOS"); flagValue = currentProvider_->enableModuleArgumentNSNullConversionIOS(); enableModuleArgumentNSNullConversionIOS_ = flagValue; @@ -866,7 +884,7 @@ bool ReactNativeFeatureFlagsAccessor::enableMountingCoordinatorPullModelAndroid( // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(46, "enableMountingCoordinatorPullModelAndroid"); + markFlagAsAccessed(47, "enableMountingCoordinatorPullModelAndroid"); flagValue = currentProvider_->enableMountingCoordinatorPullModelAndroid(); enableMountingCoordinatorPullModelAndroid_ = flagValue; @@ -884,7 +902,7 @@ bool ReactNativeFeatureFlagsAccessor::enableMutationObserverByDefault() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(47, "enableMutationObserverByDefault"); + markFlagAsAccessed(48, "enableMutationObserverByDefault"); flagValue = currentProvider_->enableMutationObserverByDefault(); enableMutationObserverByDefault_ = flagValue; @@ -902,7 +920,7 @@ bool ReactNativeFeatureFlagsAccessor::enableNativeCSSParsing() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(48, "enableNativeCSSParsing"); + markFlagAsAccessed(49, "enableNativeCSSParsing"); flagValue = currentProvider_->enableNativeCSSParsing(); enableNativeCSSParsing_ = flagValue; @@ -920,7 +938,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePreallocatedPropsDiffOnInsertAndroid // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(49, "enablePreallocatedPropsDiffOnInsertAndroid"); + markFlagAsAccessed(50, "enablePreallocatedPropsDiffOnInsertAndroid"); flagValue = currentProvider_->enablePreallocatedPropsDiffOnInsertAndroid(); enablePreallocatedPropsDiffOnInsertAndroid_ = flagValue; @@ -938,7 +956,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePreparedTextLayout() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(50, "enablePreparedTextLayout"); + markFlagAsAccessed(51, "enablePreparedTextLayout"); flagValue = currentProvider_->enablePreparedTextLayout(); enablePreparedTextLayout_ = flagValue; @@ -956,7 +974,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePropsUpdateReconciliationAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(51, "enablePropsUpdateReconciliationAndroid"); + markFlagAsAccessed(52, "enablePropsUpdateReconciliationAndroid"); flagValue = currentProvider_->enablePropsUpdateReconciliationAndroid(); enablePropsUpdateReconciliationAndroid_ = flagValue; @@ -974,7 +992,7 @@ bool ReactNativeFeatureFlagsAccessor::enableResizeObserverByDefault() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(52, "enableResizeObserverByDefault"); + markFlagAsAccessed(53, "enableResizeObserverByDefault"); flagValue = currentProvider_->enableResizeObserverByDefault(); enableResizeObserverByDefault_ = flagValue; @@ -992,7 +1010,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSwiftUIBasedFilters() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(53, "enableSwiftUIBasedFilters"); + markFlagAsAccessed(54, "enableSwiftUIBasedFilters"); flagValue = currentProvider_->enableSwiftUIBasedFilters(); enableSwiftUIBasedFilters_ = flagValue; @@ -1010,7 +1028,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewCulling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(54, "enableViewCulling"); + markFlagAsAccessed(55, "enableViewCulling"); flagValue = currentProvider_->enableViewCulling(); enableViewCulling_ = flagValue; @@ -1028,7 +1046,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecycling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(55, "enableViewRecycling"); + markFlagAsAccessed(56, "enableViewRecycling"); flagValue = currentProvider_->enableViewRecycling(); enableViewRecycling_ = flagValue; @@ -1046,7 +1064,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForImage() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(56, "enableViewRecyclingForImage"); + markFlagAsAccessed(57, "enableViewRecyclingForImage"); flagValue = currentProvider_->enableViewRecyclingForImage(); enableViewRecyclingForImage_ = flagValue; @@ -1064,7 +1082,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForScrollView() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(57, "enableViewRecyclingForScrollView"); + markFlagAsAccessed(58, "enableViewRecyclingForScrollView"); flagValue = currentProvider_->enableViewRecyclingForScrollView(); enableViewRecyclingForScrollView_ = flagValue; @@ -1082,7 +1100,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForText() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(58, "enableViewRecyclingForText"); + markFlagAsAccessed(59, "enableViewRecyclingForText"); flagValue = currentProvider_->enableViewRecyclingForText(); enableViewRecyclingForText_ = flagValue; @@ -1100,7 +1118,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForView() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(59, "enableViewRecyclingForView"); + markFlagAsAccessed(60, "enableViewRecyclingForView"); flagValue = currentProvider_->enableViewRecyclingForView(); enableViewRecyclingForView_ = flagValue; @@ -1118,7 +1136,7 @@ bool ReactNativeFeatureFlagsAccessor::enableVirtualViewContainerStateExperimenta // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(60, "enableVirtualViewContainerStateExperimental"); + markFlagAsAccessed(61, "enableVirtualViewContainerStateExperimental"); flagValue = currentProvider_->enableVirtualViewContainerStateExperimental(); enableVirtualViewContainerStateExperimental_ = flagValue; @@ -1136,7 +1154,7 @@ bool ReactNativeFeatureFlagsAccessor::fixBorderlessRippleAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(61, "fixBorderlessRippleAndroid"); + markFlagAsAccessed(62, "fixBorderlessRippleAndroid"); flagValue = currentProvider_->fixBorderlessRippleAndroid(); fixBorderlessRippleAndroid_ = flagValue; @@ -1154,7 +1172,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMappingOfEventPrioritiesBetweenFabricAn // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(62, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); + markFlagAsAccessed(63, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact(); fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue; @@ -1172,7 +1190,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMultilineContentJumpAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(63, "fixMultilineContentJumpAndroid"); + markFlagAsAccessed(64, "fixMultilineContentJumpAndroid"); flagValue = currentProvider_->fixMultilineContentJumpAndroid(); fixMultilineContentJumpAndroid_ = flagValue; @@ -1190,7 +1208,7 @@ bool ReactNativeFeatureFlagsAccessor::fixProgrammaticScrollMomentumEventsIOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(64, "fixProgrammaticScrollMomentumEventsIOS"); + markFlagAsAccessed(65, "fixProgrammaticScrollMomentumEventsIOS"); flagValue = currentProvider_->fixProgrammaticScrollMomentumEventsIOS(); fixProgrammaticScrollMomentumEventsIOS_ = flagValue; @@ -1208,7 +1226,7 @@ bool ReactNativeFeatureFlagsAccessor::fixTextInlineViewLineHeight() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(65, "fixTextInlineViewLineHeight"); + markFlagAsAccessed(66, "fixTextInlineViewLineHeight"); flagValue = currentProvider_->fixTextInlineViewLineHeight(); fixTextInlineViewLineHeight_ = flagValue; @@ -1226,7 +1244,7 @@ bool ReactNativeFeatureFlagsAccessor::fixTextLayoutOnPixelDensityChange() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(66, "fixTextLayoutOnPixelDensityChange"); + markFlagAsAccessed(67, "fixTextLayoutOnPixelDensityChange"); flagValue = currentProvider_->fixTextLayoutOnPixelDensityChange(); fixTextLayoutOnPixelDensityChange_ = flagValue; @@ -1244,7 +1262,7 @@ bool ReactNativeFeatureFlagsAccessor::fixYogaFlexBasisFitContentInMainAxis() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(67, "fixYogaFlexBasisFitContentInMainAxis"); + markFlagAsAccessed(68, "fixYogaFlexBasisFitContentInMainAxis"); flagValue = currentProvider_->fixYogaFlexBasisFitContentInMainAxis(); fixYogaFlexBasisFitContentInMainAxis_ = flagValue; @@ -1262,7 +1280,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxAssertSingleHostState() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(68, "fuseboxAssertSingleHostState"); + markFlagAsAccessed(69, "fuseboxAssertSingleHostState"); flagValue = currentProvider_->fuseboxAssertSingleHostState(); fuseboxAssertSingleHostState_ = flagValue; @@ -1280,7 +1298,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxEnabledRelease() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(69, "fuseboxEnabledRelease"); + markFlagAsAccessed(70, "fuseboxEnabledRelease"); flagValue = currentProvider_->fuseboxEnabledRelease(); fuseboxEnabledRelease_ = flagValue; @@ -1298,7 +1316,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxFrameRecordingEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(70, "fuseboxFrameRecordingEnabled"); + markFlagAsAccessed(71, "fuseboxFrameRecordingEnabled"); flagValue = currentProvider_->fuseboxFrameRecordingEnabled(); fuseboxFrameRecordingEnabled_ = flagValue; @@ -1316,7 +1334,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxScreenshotCaptureEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(71, "fuseboxScreenshotCaptureEnabled"); + markFlagAsAccessed(72, "fuseboxScreenshotCaptureEnabled"); flagValue = currentProvider_->fuseboxScreenshotCaptureEnabled(); fuseboxScreenshotCaptureEnabled_ = flagValue; @@ -1334,7 +1352,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxWebSocketEventsEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(72, "fuseboxWebSocketEventsEnabled"); + markFlagAsAccessed(73, "fuseboxWebSocketEventsEnabled"); flagValue = currentProvider_->fuseboxWebSocketEventsEnabled(); fuseboxWebSocketEventsEnabled_ = flagValue; @@ -1352,7 +1370,7 @@ bool ReactNativeFeatureFlagsAccessor::keepTimersRunningWhileHostPausedAndroid() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(73, "keepTimersRunningWhileHostPausedAndroid"); + markFlagAsAccessed(74, "keepTimersRunningWhileHostPausedAndroid"); flagValue = currentProvider_->keepTimersRunningWhileHostPausedAndroid(); keepTimersRunningWhileHostPausedAndroid_ = flagValue; @@ -1370,7 +1388,7 @@ bool ReactNativeFeatureFlagsAccessor::optimizedAnimatedPropUpdates() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(74, "optimizedAnimatedPropUpdates"); + markFlagAsAccessed(75, "optimizedAnimatedPropUpdates"); flagValue = currentProvider_->optimizedAnimatedPropUpdates(); optimizedAnimatedPropUpdates_ = flagValue; @@ -1388,7 +1406,7 @@ bool ReactNativeFeatureFlagsAccessor::overrideBySynchronousMountPropsAtMountingA // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(75, "overrideBySynchronousMountPropsAtMountingAndroid"); + markFlagAsAccessed(76, "overrideBySynchronousMountPropsAtMountingAndroid"); flagValue = currentProvider_->overrideBySynchronousMountPropsAtMountingAndroid(); overrideBySynchronousMountPropsAtMountingAndroid_ = flagValue; @@ -1406,7 +1424,7 @@ bool ReactNativeFeatureFlagsAccessor::perfIssuesEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(76, "perfIssuesEnabled"); + markFlagAsAccessed(77, "perfIssuesEnabled"); flagValue = currentProvider_->perfIssuesEnabled(); perfIssuesEnabled_ = flagValue; @@ -1424,7 +1442,7 @@ bool ReactNativeFeatureFlagsAccessor::perfMonitorV2Enabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(77, "perfMonitorV2Enabled"); + markFlagAsAccessed(78, "perfMonitorV2Enabled"); flagValue = currentProvider_->perfMonitorV2Enabled(); perfMonitorV2Enabled_ = flagValue; @@ -1442,7 +1460,7 @@ double ReactNativeFeatureFlagsAccessor::preparedTextCacheSize() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(78, "preparedTextCacheSize"); + markFlagAsAccessed(79, "preparedTextCacheSize"); flagValue = currentProvider_->preparedTextCacheSize(); preparedTextCacheSize_ = flagValue; @@ -1460,7 +1478,7 @@ bool ReactNativeFeatureFlagsAccessor::preventShadowTreeCommitExhaustion() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(79, "preventShadowTreeCommitExhaustion"); + markFlagAsAccessed(80, "preventShadowTreeCommitExhaustion"); flagValue = currentProvider_->preventShadowTreeCommitExhaustion(); preventShadowTreeCommitExhaustion_ = flagValue; @@ -1478,7 +1496,7 @@ bool ReactNativeFeatureFlagsAccessor::redBoxV2Android() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(80, "redBoxV2Android"); + markFlagAsAccessed(81, "redBoxV2Android"); flagValue = currentProvider_->redBoxV2Android(); redBoxV2Android_ = flagValue; @@ -1496,7 +1514,7 @@ bool ReactNativeFeatureFlagsAccessor::redBoxV2IOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(81, "redBoxV2IOS"); + markFlagAsAccessed(82, "redBoxV2IOS"); flagValue = currentProvider_->redBoxV2IOS(); redBoxV2IOS_ = flagValue; @@ -1514,7 +1532,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldPressibilityUseW3CPointerEventsForHo // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(82, "shouldPressibilityUseW3CPointerEventsForHover"); + markFlagAsAccessed(83, "shouldPressibilityUseW3CPointerEventsForHover"); flagValue = currentProvider_->shouldPressibilityUseW3CPointerEventsForHover(); shouldPressibilityUseW3CPointerEventsForHover_ = flagValue; @@ -1532,7 +1550,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldTriggerResponderTransferOnScrollAndr // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(83, "shouldTriggerResponderTransferOnScrollAndroid"); + markFlagAsAccessed(84, "shouldTriggerResponderTransferOnScrollAndroid"); flagValue = currentProvider_->shouldTriggerResponderTransferOnScrollAndroid(); shouldTriggerResponderTransferOnScrollAndroid_ = flagValue; @@ -1550,7 +1568,7 @@ bool ReactNativeFeatureFlagsAccessor::skipActivityIdentityAssertionOnHostPause() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(84, "skipActivityIdentityAssertionOnHostPause"); + markFlagAsAccessed(85, "skipActivityIdentityAssertionOnHostPause"); flagValue = currentProvider_->skipActivityIdentityAssertionOnHostPause(); skipActivityIdentityAssertionOnHostPause_ = flagValue; @@ -1568,7 +1586,7 @@ bool ReactNativeFeatureFlagsAccessor::skipNativePropsForViewManagerWithDelegateA // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(85, "skipNativePropsForViewManagerWithDelegateAndroid"); + markFlagAsAccessed(86, "skipNativePropsForViewManagerWithDelegateAndroid"); flagValue = currentProvider_->skipNativePropsForViewManagerWithDelegateAndroid(); skipNativePropsForViewManagerWithDelegateAndroid_ = flagValue; @@ -1586,7 +1604,7 @@ bool ReactNativeFeatureFlagsAccessor::skipUnchangedChildrenInDifferentiator() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(86, "skipUnchangedChildrenInDifferentiator"); + markFlagAsAccessed(87, "skipUnchangedChildrenInDifferentiator"); flagValue = currentProvider_->skipUnchangedChildrenInDifferentiator(); skipUnchangedChildrenInDifferentiator_ = flagValue; @@ -1604,7 +1622,7 @@ bool ReactNativeFeatureFlagsAccessor::syncAndroidClipBoundsWithOverflow() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(87, "syncAndroidClipBoundsWithOverflow"); + markFlagAsAccessed(88, "syncAndroidClipBoundsWithOverflow"); flagValue = currentProvider_->syncAndroidClipBoundsWithOverflow(); syncAndroidClipBoundsWithOverflow_ = flagValue; @@ -1622,7 +1640,7 @@ bool ReactNativeFeatureFlagsAccessor::traceTurboModulePromiseRejectionsOnAndroid // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(88, "traceTurboModulePromiseRejectionsOnAndroid"); + markFlagAsAccessed(89, "traceTurboModulePromiseRejectionsOnAndroid"); flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid(); traceTurboModulePromiseRejectionsOnAndroid_ = flagValue; @@ -1640,7 +1658,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommit( // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(89, "updateRuntimeShadowNodeReferencesOnCommit"); + markFlagAsAccessed(90, "updateRuntimeShadowNodeReferencesOnCommit"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommit(); updateRuntimeShadowNodeReferencesOnCommit_ = flagValue; @@ -1658,7 +1676,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommitT // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(90, "updateRuntimeShadowNodeReferencesOnCommitThread"); + markFlagAsAccessed(91, "updateRuntimeShadowNodeReferencesOnCommitThread"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommitThread(); updateRuntimeShadowNodeReferencesOnCommitThread_ = flagValue; @@ -1676,7 +1694,7 @@ bool ReactNativeFeatureFlagsAccessor::useAlwaysAvailableJSErrorHandling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(91, "useAlwaysAvailableJSErrorHandling"); + markFlagAsAccessed(92, "useAlwaysAvailableJSErrorHandling"); flagValue = currentProvider_->useAlwaysAvailableJSErrorHandling(); useAlwaysAvailableJSErrorHandling_ = flagValue; @@ -1694,7 +1712,7 @@ bool ReactNativeFeatureFlagsAccessor::useFabricInterop() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(92, "useFabricInterop"); + markFlagAsAccessed(93, "useFabricInterop"); flagValue = currentProvider_->useFabricInterop(); useFabricInterop_ = flagValue; @@ -1712,7 +1730,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeViewConfigsInBridgelessMode() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(93, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(94, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -1730,7 +1748,7 @@ bool ReactNativeFeatureFlagsAccessor::useNestedScrollViewAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(94, "useNestedScrollViewAndroid"); + markFlagAsAccessed(95, "useNestedScrollViewAndroid"); flagValue = currentProvider_->useNestedScrollViewAndroid(); useNestedScrollViewAndroid_ = flagValue; @@ -1748,7 +1766,7 @@ bool ReactNativeFeatureFlagsAccessor::useSharedAnimatedBackend() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(95, "useSharedAnimatedBackend"); + markFlagAsAccessed(96, "useSharedAnimatedBackend"); flagValue = currentProvider_->useSharedAnimatedBackend(); useSharedAnimatedBackend_ = flagValue; @@ -1766,7 +1784,7 @@ bool ReactNativeFeatureFlagsAccessor::useTraitHiddenOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(96, "useTraitHiddenOnAndroid"); + markFlagAsAccessed(97, "useTraitHiddenOnAndroid"); flagValue = currentProvider_->useTraitHiddenOnAndroid(); useTraitHiddenOnAndroid_ = flagValue; @@ -1784,7 +1802,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(97, "useTurboModuleInterop"); + markFlagAsAccessed(98, "useTurboModuleInterop"); flagValue = currentProvider_->useTurboModuleInterop(); useTurboModuleInterop_ = flagValue; @@ -1802,7 +1820,7 @@ bool ReactNativeFeatureFlagsAccessor::useWindowDensityForDisplayMetricsAndroid() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(98, "useWindowDensityForDisplayMetricsAndroid"); + markFlagAsAccessed(99, "useWindowDensityForDisplayMetricsAndroid"); flagValue = currentProvider_->useWindowDensityForDisplayMetricsAndroid(); useWindowDensityForDisplayMetricsAndroid_ = flagValue; @@ -1820,7 +1838,7 @@ double ReactNativeFeatureFlagsAccessor::viewCullingOutsetRatio() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(99, "viewCullingOutsetRatio"); + markFlagAsAccessed(100, "viewCullingOutsetRatio"); flagValue = currentProvider_->viewCullingOutsetRatio(); viewCullingOutsetRatio_ = flagValue; @@ -1838,7 +1856,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(100, "viewTransitionEnabled"); + markFlagAsAccessed(101, "viewTransitionEnabled"); flagValue = currentProvider_->viewTransitionEnabled(); viewTransitionEnabled_ = flagValue; @@ -1856,7 +1874,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionUseHardwareBitmapAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(101, "viewTransitionUseHardwareBitmapAndroid"); + markFlagAsAccessed(102, "viewTransitionUseHardwareBitmapAndroid"); flagValue = currentProvider_->viewTransitionUseHardwareBitmapAndroid(); viewTransitionUseHardwareBitmapAndroid_ = flagValue; @@ -1874,7 +1892,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewPrerenderRatio() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(102, "virtualViewPrerenderRatio"); + markFlagAsAccessed(103, "virtualViewPrerenderRatio"); flagValue = currentProvider_->virtualViewPrerenderRatio(); virtualViewPrerenderRatio_ = flagValue; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h index b298365059d6..d4616bebccd7 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<8b81c2a9ef5b462a5c28d96133545537>> + * @generated SignedSource<<9f2e67fdc5a5e9e452b59c47ceb68411>> */ /** @@ -62,6 +62,7 @@ class ReactNativeFeatureFlagsAccessor { bool enableFabricCommitBranchingMergeOnMainThread(); bool enableFabricLogs(); bool enableFlexboxAutoMinSizeInStrictMode(); + bool enableFlushSync(); bool enableFollowUpMountItemDispatchAndroid(); bool enableIOSCompressedTextFrameAdjustment(); bool enableIOSTextBaselineOffsetPerLine(); @@ -148,7 +149,7 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 103> accessedFeatureFlags_; + std::array, 104> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> cdpInteractionMetricsEnabled_; @@ -178,6 +179,7 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> enableFabricCommitBranchingMergeOnMainThread_; std::atomic> enableFabricLogs_; std::atomic> enableFlexboxAutoMinSizeInStrictMode_; + std::atomic> enableFlushSync_; std::atomic> enableFollowUpMountItemDispatchAndroid_; std::atomic> enableIOSCompressedTextFrameAdjustment_; std::atomic> enableIOSTextBaselineOffsetPerLine_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index 7d90d55dbba7..c67cef573d76 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3f0de97f1127a4c958beb355dd89aa49>> + * @generated SignedSource<<7a81ab39c483265b1e958b1091a60778>> */ /** @@ -141,6 +141,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } + bool enableFlushSync() override { + return false; + } + bool enableFollowUpMountItemDispatchAndroid() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h index 7808d04f3dc3..65d27bd4f55e 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<14e648942ae5983397e77b3836005a7c>> + * @generated SignedSource<<224a696e6d9f5af0cc450c8742d565e2>> */ /** @@ -299,6 +299,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef return ReactNativeFeatureFlagsDefaults::enableFlexboxAutoMinSizeInStrictMode(); } + bool enableFlushSync() override { + auto value = values_["enableFlushSync"]; + if (!value.isNull()) { + return value.getBool(); + } + + return ReactNativeFeatureFlagsDefaults::enableFlushSync(); + } + bool enableFollowUpMountItemDispatchAndroid() override { auto value = values_["enableFollowUpMountItemDispatchAndroid"]; if (!value.isNull()) { diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index cb3c4f972876..7a33d63c5c35 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<03e36dccc314d85a3431d62aceb1174a>> + * @generated SignedSource<<8aa886405e9e5978c6572980119d7ea9>> */ /** @@ -55,6 +55,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool enableFabricCommitBranchingMergeOnMainThread() = 0; virtual bool enableFabricLogs() = 0; virtual bool enableFlexboxAutoMinSizeInStrictMode() = 0; + virtual bool enableFlushSync() = 0; virtual bool enableFollowUpMountItemDispatchAndroid() = 0; virtual bool enableIOSCompressedTextFrameAdjustment() = 0; virtual bool enableIOSTextBaselineOffsetPerLine() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index baad12f49355..3184a83f67ac 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<6190f5f54c0ccd6946599bb1bbb3c1aa>> + * @generated SignedSource<<1b5afe4df88834163a9e8a39ca24dd15>> */ /** @@ -184,6 +184,11 @@ bool NativeReactNativeFeatureFlags::enableFlexboxAutoMinSizeInStrictMode( return ReactNativeFeatureFlags::enableFlexboxAutoMinSizeInStrictMode(); } +bool NativeReactNativeFeatureFlags::enableFlushSync( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::enableFlushSync(); +} + bool NativeReactNativeFeatureFlags::enableFollowUpMountItemDispatchAndroid( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::enableFollowUpMountItemDispatchAndroid(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index 3113b0d701d3..c0d6598a33b9 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<9d8b1c429f086297c38b67f8db77c566>> + * @generated SignedSource<<9829941034a694056c0baf2f2e7e6574>> */ /** @@ -94,6 +94,8 @@ class NativeReactNativeFeatureFlags bool enableFlexboxAutoMinSizeInStrictMode(jsi::Runtime& runtime); + bool enableFlushSync(jsi::Runtime& runtime); + bool enableFollowUpMountItemDispatchAndroid(jsi::Runtime& runtime); bool enableIOSCompressedTextFrameAdjustment(jsi::Runtime& runtime); diff --git a/packages/react-native/index.js b/packages/react-native/index.js index 24f2c7085e59..0b39b9838871 100644 --- a/packages/react-native/index.js +++ b/packages/react-native/index.js @@ -349,6 +349,16 @@ module.exports = { return require('./Libraries/ReactNative/RendererProxy').findNodeHandle; }, // $FlowFixMe[unsafe-getters-setters] + get unstable_flushSync() { + // Only available when the `enableFlushSync` feature flag is enabled. + if ( + !require('./src/private/featureflags/ReactNativeFeatureFlags').enableFlushSync() + ) { + return undefined; + } + return require('./Libraries/ReactNative/RendererProxy').flushSync; + }, + // $FlowFixMe[unsafe-getters-setters] get I18nManager() { return require('./Libraries/ReactNative/I18nManager').default; }, diff --git a/packages/react-native/index.js.flow b/packages/react-native/index.js.flow index d1397e29920b..99e503e2745c 100644 --- a/packages/react-native/index.js.flow +++ b/packages/react-native/index.js.flow @@ -324,6 +324,9 @@ export type {EasingFunction} from './Libraries/Animated/Easing'; export {default as Easing} from './Libraries/Animated/Easing'; export {findNodeHandle} from './Libraries/ReactNative/RendererProxy'; +import {flushSync as RendererProxyFlushSync} from './Libraries/ReactNative/RendererProxy'; +// Only available when the `enableFlushSync` feature flag is enabled. +declare export const unstable_flushSync: ?typeof RendererProxyFlushSync; export {default as I18nManager} from './Libraries/ReactNative/I18nManager'; diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index f5a64f8e509f..e030600d90b6 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -352,6 +352,16 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'experimental', }, + enableFlushSync: { + defaultValue: false, + metadata: { + description: + 'Exposes `unstable_flushSync` from the `react-native` package, with the same semantics as `flushSync` from `react-dom`.', + expectedReleaseValue: true, + purpose: 'release', + }, + ossReleaseStage: 'none', + }, enableFollowUpMountItemDispatchAndroid: { defaultValue: false, metadata: { diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index f6b8c08419be..60509629c603 100644 --- a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<581558c9591efde03b925773bbf05e66>> * @flow strict * @noformat */ @@ -77,6 +77,7 @@ export type ReactNativeFeatureFlags = Readonly<{ enableFabricCommitBranchingMergeOnMainThread: Getter, enableFabricLogs: Getter, enableFlexboxAutoMinSizeInStrictMode: Getter, + enableFlushSync: Getter, enableFollowUpMountItemDispatchAndroid: Getter, enableIOSCompressedTextFrameAdjustment: Getter, enableIOSTextBaselineOffsetPerLine: Getter, @@ -340,6 +341,10 @@ export const enableFabricLogs: Getter = createNativeFlagGetter('enableF * Enables CSS Flexbox ยง4.5 automatic minimum sizing under strict layout conformance. When enabled, a flex item with an undefined main-axis `min-width`/`min-height` under strict conformance receives a content-derived minimum size (per spec) instead of an undefined (0) minimum. Defaults off so the behaviour can be ramped independently of strict conformance. */ export const enableFlexboxAutoMinSizeInStrictMode: Getter = createNativeFlagGetter('enableFlexboxAutoMinSizeInStrictMode', false); +/** + * Exposes `unstable_flushSync` from the `react-native` package, with the same semantics as `flushSync` from `react-dom`. + */ +export const enableFlushSync: Getter = createNativeFlagGetter('enableFlushSync', false); /** * When mount items are queued while MountItemDispatcher is already dispatching on Android (e.g. from a synchronous state update), dispatch them in the same frame instead of deferring them to the next one. */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index 7b0bd4e5e4a9..e01580594e2b 100644 --- a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<21711915af041d88c306bc5f671f0622>> + * @generated SignedSource<<5fc3f6a14b4e46e34e89fe358e57183b>> * @flow strict * @noformat */ @@ -53,6 +53,7 @@ export interface Spec extends TurboModule { readonly enableFabricCommitBranchingMergeOnMainThread?: () => boolean; readonly enableFabricLogs?: () => boolean; readonly enableFlexboxAutoMinSizeInStrictMode?: () => boolean; + readonly enableFlushSync?: () => boolean; readonly enableFollowUpMountItemDispatchAndroid?: () => boolean; readonly enableIOSCompressedTextFrameAdjustment?: () => boolean; readonly enableIOSTextBaselineOffsetPerLine?: () => boolean; diff --git a/packages/react-native/src/private/webapis/resizeobserver/__tests__/ResizeObserver-itest.js b/packages/react-native/src/private/webapis/resizeobserver/__tests__/ResizeObserver-itest.js index d43bb25277fe..c60e49c5865f 100644 --- a/packages/react-native/src/private/webapis/resizeobserver/__tests__/ResizeObserver-itest.js +++ b/packages/react-native/src/private/webapis/resizeobserver/__tests__/ResizeObserver-itest.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @fantom_flags enableResizeObserverByDefault:true enableFabricCommitBranching:* + * @fantom_flags enableResizeObserverByDefault:true enableFabricCommitBranching:* enableFlushSync:true * @flow strict-local * @format */ @@ -22,8 +22,8 @@ import NativeFantom from '../../../testing/fantom/specs/NativeFantom'; import * as Fantom from '@react-native/fantom'; import nullthrows from 'nullthrows'; import * as React from 'react'; -import {createRef, useLayoutEffect} from 'react'; -import {View} from 'react-native'; +import {createRef, useLayoutEffect, useState} from 'react'; +import {View, unstable_flushSync as flushSync} from 'react-native'; declare const ResizeObserver: Class; declare const ResizeObserverEntry: Class; @@ -2449,6 +2449,86 @@ describe('ResizeObserver', () => { // its layout reads must still resolve to the commit it reports on. expect(observed).toEqual(['100:100', '200:200']); }); + + describe('updates from the callback', () => { + function renderBoxReactingToResize( + updateChild: (update: () => void) => void, + ): { + root: Fantom.Root, + resizeAndGetMountedLogsAfterPaint: () => ReadonlyArray, + } { + const root = Fantom.createRoot(); + const nodeRef = createRef(); + let setShowChild: (showChild: boolean) => void = () => {}; + + component Box(width: number) { + const [showChild, _setShowChild] = useState(false); + setShowChild = _setShowChild; + return ( + + {showChild ? : null} + + ); + } + + Fantom.runTask(() => { + root.render(); + }); + + let logsAfterPaint: ?ReadonlyArray = null; + Fantom.runTask(() => { + observer = new ResizeObserver(entries => { + if (entries[0].contentRect.width !== 200) { + return; + } + // Scheduled before the update, so it runs right after the paint + // for this layout pass (and before any React task it schedules). + Fantom.scheduleTask(() => { + logsAfterPaint = root.takeMountingManagerLogs(); + }); + updateChild(() => setShowChild(true)); + }); + observer.observe(nullthrows(nodeRef.current)); + }); + root.takeMountingManagerLogs(); + + return { + root, + resizeAndGetMountedLogsAfterPaint: () => { + Fantom.runTask(() => { + root.render(); + }); + return nullthrows(logsAfterPaint); + }, + }; + } + + it('should paint updates flushed with flushSync in the same layout pass', () => { + const {root, resizeAndGetMountedLogsAfterPaint} = + renderBoxReactingToResize(update => nullthrows(flushSync)(update)); + + const logsAfterPaint = resizeAndGetMountedLogsAfterPaint(); + + expect(logsAfterPaint).toContain( + 'Create {type: "View", nativeID: "child"}', + ); + expect(root.takeMountingManagerLogs()).toEqual([]); + }); + + it('should paint updates not flushed with flushSync in a later layout pass', () => { + const {root, resizeAndGetMountedLogsAfterPaint} = + renderBoxReactingToResize(update => update()); + + const logsAfterPaint = resizeAndGetMountedLogsAfterPaint(); + + expect(logsAfterPaint).not.toContain( + 'Create {type: "View", nativeID: "child"}', + ); + expect(root.takeMountingManagerLogs()).toContain( + 'Create {type: "View", nativeID: "child"}', + ); + }); + }); }); describe('callback error handling', () => {