Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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.
*
* @generated SignedSource<<95f86b3476aeff097f532b10cabf067e>>
*/

/**
* IMPORTANT: Do NOT modify this file directly.
*
* To change the definition of the flags, edit
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags --update
*/

#include "ReactNativeFeatureFlags.h"
#include "ReactNativePublicFeatureFlags.h"

namespace facebook::react {

bool ReactNativeFeatureFlags_DO_NOT_USE::enableAccumulatedUpdatesInRawPropsAndroid() {
return ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid();
}

bool ReactNativeFeatureFlags_DO_NOT_USE::enableCppPropsIteratorSetter() {
return ReactNativeFeatureFlags::enableCppPropsIteratorSetter();
}

bool ReactNativeFeatureFlags_DO_NOT_USE::enableExclusivePropsUpdateAndroid() {
return ReactNativeFeatureFlags::enableExclusivePropsUpdateAndroid();
}

bool ReactNativeFeatureFlags_DO_NOT_USE::enableNativeCSSParsing() {
return ReactNativeFeatureFlags::enableNativeCSSParsing();
}

bool ReactNativeFeatureFlags_DO_NOT_USE::enablePropsUpdateReconciliationAndroid() {
return ReactNativeFeatureFlags::enablePropsUpdateReconciliationAndroid();
}

bool ReactNativeFeatureFlags_DO_NOT_USE::useSharedAnimatedBackend() {
return ReactNativeFeatureFlags::useSharedAnimatedBackend();
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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.
*
* @generated SignedSource<<39037a69a47b86d0c6643d90f4058002>>
*/

/**
* IMPORTANT: Do NOT modify this file directly.
*
* To change the definition of the flags, edit
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags --update
*/

#pragma once

#include <string>

#ifndef RN_EXPORT
#define RN_EXPORT __attribute__((visibility("default")))
#endif

namespace facebook::react {

/**
* This class provides public access to select internal React Native feature flags.
*/
class ReactNativeFeatureFlags_DO_NOT_USE {
public:
/**
* When enabled, Android will accumulate updates in rawProps to reduce the number of mounting instructions for cascading re-renders.
*/
RN_EXPORT static bool enableAccumulatedUpdatesInRawPropsAndroid();

/**
* Enable prop iterator setter-style construction of Props in C++ (this flag is not used in Java).
*/
RN_EXPORT static bool enableCppPropsIteratorSetter();

/**
* When enabled, Android will disable Props 1.5 raw value merging when Props 2.0 is available.
*/
RN_EXPORT static bool enableExclusivePropsUpdateAndroid();

/**
* Parse CSS strings using the Fabric CSS parser instead of ViewConfig processing
*/
RN_EXPORT static bool enableNativeCSSParsing();

/**
* When enabled, Android will receive prop updates based on the differences between the last rendered shadow node and the last committed shadow node.
*/
RN_EXPORT static bool enablePropsUpdateReconciliationAndroid();

/**
* Use shared animation backend in C++ Animated
*/
RN_EXPORT static bool useSharedAnimatedBackend();
};

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <react/cxxstableapi/FrameworksGuard.h>

#include <react/debug/react_native_expect.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/featureflags/ReactNativePublicFeatureFlags.h>
#include <react/renderer/attributedstring/AttributedString.h>
#include <react/renderer/attributedstring/ParagraphAttributes.h>
#include <react/renderer/attributedstring/TextAttributes.h>
Expand Down Expand Up @@ -517,7 +517,7 @@ inline void parseUnprocessedFontVariant(const PropsParserContext &context, const

inline void fromRawValue(const PropsParserContext &context, const RawValue &value, FontVariant &result)
{
if (ReactNativeFeatureFlags::enableNativeCSSParsing()) {
if (ReactNativeFeatureFlags_DO_NOT_USE::enableNativeCSSParsing()) {
parseUnprocessedFontVariant(context, value, result);
} else {
parseProcessedFontVariant(context, value, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <react/cxxstableapi/UmbrellaGuard.h>

#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/featureflags/ReactNativePublicFeatureFlags.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/RawProps.h>
#include <react/renderer/graphics/BackgroundImage.h>
Expand All @@ -30,7 +30,7 @@ void parseUnprocessedBackgroundImageString(const std::string &value, std::vector

inline void fromRawValue(const PropsParserContext &context, const RawValue &value, std::vector<BackgroundImage> &result)
{
if (ReactNativeFeatureFlags::enableNativeCSSParsing()) {
if (ReactNativeFeatureFlags_DO_NOT_USE::enableNativeCSSParsing()) {
if (value.hasType<std::string>()) {
parseUnprocessedBackgroundImageString((std::string)value, result);
} else if (value.hasType<std::vector<RawValue>>()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <glog/logging.h>
#include <react/debug/react_native_expect.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/featureflags/ReactNativePublicFeatureFlags.h>
#include <react/renderer/components/view/CSSConversions.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/RawProps.h>
Expand Down Expand Up @@ -255,7 +255,7 @@ parseUnprocessedBoxShadow(const PropsParserContext &context, const RawValue &val

inline void fromRawValue(const PropsParserContext &context, const RawValue &value, std::vector<BoxShadow> &result)
{
if (ReactNativeFeatureFlags::enableNativeCSSParsing()) {
if (ReactNativeFeatureFlags_DO_NOT_USE::enableNativeCSSParsing()) {
parseUnprocessedBoxShadow(context, value, result);
} else {
parseProcessedBoxShadow(context, value, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <glog/logging.h>
#include <react/debug/react_native_expect.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/featureflags/ReactNativePublicFeatureFlags.h>
#include <react/renderer/components/view/CSSConversions.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/RawProps.h>
Expand Down Expand Up @@ -358,7 +358,7 @@ parseUnprocessedFilter(const PropsParserContext &context, const RawValue &value,

inline void fromRawValue(const PropsParserContext &context, const RawValue &value, std::vector<FilterFunction> &result)
{
if (ReactNativeFeatureFlags::enableNativeCSSParsing()) {
if (ReactNativeFeatureFlags_DO_NOT_USE::enableNativeCSSParsing()) {
parseUnprocessedFilter(context, value, result);
} else {
parseProcessedFilter(context, value, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <glog/logging.h>
#include <react/debug/react_native_expect.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/featureflags/ReactNativePublicFeatureFlags.h>
#include <react/renderer/components/view/primitives.h>
#include <react/renderer/core/LayoutMetrics.h>
#include <react/renderer/core/PropsParserContext.h>
Expand Down Expand Up @@ -520,7 +520,7 @@ inline yoga::FloatOptional convertAspectRatio(const PropsParserContext & /*conte
if (value.hasType<float>()) {
return yoga::FloatOptional((float)value);
}
if (ReactNativeFeatureFlags::enableNativeCSSParsing() && value.hasType<std::string>()) {
if (ReactNativeFeatureFlags_DO_NOT_USE::enableNativeCSSParsing() && value.hasType<std::string>()) {
auto ratio = parseCSSProperty<CSSRatio>((std::string)value);
if (std::holds_alternative<CSSRatio>(ratio)) {
auto r = std::get<CSSRatio>(ratio);
Expand Down Expand Up @@ -995,7 +995,7 @@ inline void parseUnprocessedTransform(const PropsParserContext &context, const R

inline void fromRawValue(const PropsParserContext &context, const RawValue &value, Transform &result)
{
if (ReactNativeFeatureFlags::enableNativeCSSParsing()) {
if (ReactNativeFeatureFlags_DO_NOT_USE::enableNativeCSSParsing()) {
parseUnprocessedTransform(context, value, result);
} else {
parseProcessedTransform(context, value, result);
Expand Down Expand Up @@ -1079,7 +1079,7 @@ parseUnprocessedTransformOrigin(const PropsParserContext &context, const RawValu

inline void fromRawValue(const PropsParserContext &context, const RawValue &value, TransformOrigin &result)
{
if (ReactNativeFeatureFlags::enableNativeCSSParsing()) {
if (ReactNativeFeatureFlags_DO_NOT_USE::enableNativeCSSParsing()) {
parseUnprocessedTransformOrigin(context, value, result);
} else {
parseProcessedTransformOrigin(context, value, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <vector>

#include <react/debug/react_native_assert.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/featureflags/ReactNativePublicFeatureFlags.h>
#include <react/renderer/core/ComponentDescriptor.h>
#include <react/renderer/core/EventDispatcher.h>
#include <react/renderer/core/Props.h>
Expand Down Expand Up @@ -56,7 +56,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
// iterator-setter path and the runtime flag is on, `parse()` is never
// called, so the O(n²) preparation here is wasted. Skip it.
if constexpr (HasIteratorSetterCtor<ConcreteProps>) {
if (!ReactNativeFeatureFlags::enableCppPropsIteratorSetter()) {
if (!ReactNativeFeatureFlags_DO_NOT_USE::enableCppPropsIteratorSetter()) {
rawPropsParser_.prepare<ConcreteProps>();
}
} else {
Expand Down Expand Up @@ -136,7 +136,8 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
// and the only path when the flag is off): parse + per-field
// `convertRawProp` via the 3-arg ctor.
constexpr bool kSupportsIteratorSetter = HasIteratorSetterCtor<ConcreteProps>;
const bool useIteratorSetter = kSupportsIteratorSetter && ReactNativeFeatureFlags::enableCppPropsIteratorSetter();
const bool useIteratorSetter =
kSupportsIteratorSetter && ReactNativeFeatureFlags_DO_NOT_USE::enableCppPropsIteratorSetter();

std::shared_ptr<ConcreteProps> shadowNodeProps;
if constexpr (kSupportsIteratorSetter) {
Expand All @@ -151,11 +152,11 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {

#ifdef RN_SERIALIZABLE_STATE
bool fallbackToDynamicRawPropsAccumulation = true;
if (ReactNativeFeatureFlags::enableExclusivePropsUpdateAndroid() &&
ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid()) {
if (ReactNativeFeatureFlags_DO_NOT_USE::enableExclusivePropsUpdateAndroid() &&
ReactNativeFeatureFlags_DO_NOT_USE::enableAccumulatedUpdatesInRawPropsAndroid()) {
// When exclusive props update is enabled, we only apply Props 1.5 processing
// (raw props merging) when Props 2.0 is not available.
if (ReactNativeFeatureFlags::enablePropsUpdateReconciliationAndroid()) {
if (ReactNativeFeatureFlags_DO_NOT_USE::enablePropsUpdateReconciliationAndroid()) {
// Cast to base Props reference to safely call virtual method
const auto &baseProps = static_cast<const Props &>(*shadowNodeProps);
if (strcmp(ShadowNodeT::Name(), baseProps.getDiffPropsImplementationTarget()) == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <react/cxxstableapi/UmbrellaGuard.h>
#include <react/debug/react_native_expect.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/featureflags/ReactNativePublicFeatureFlags.h>
#include <react/renderer/core/RawValue.h>
#include <react/renderer/css/CSSColor.h>
#include <react/renderer/css/CSSValueParser.h>
Expand All @@ -28,7 +28,7 @@ inline void fromRawValueShared(
{
ColorComponents colorComponents = {0, 0, 0, 0};

if (ReactNativeFeatureFlags::enableNativeCSSParsing() && value.hasType<std::string>()) {
if (ReactNativeFeatureFlags_DO_NOT_USE::enableNativeCSSParsing() && value.hasType<std::string>()) {
auto cssColor = parseCSSProperty<CSSColor>((std::string)value);
if (std::holds_alternative<CSSColor>(cssColor)) {
auto c = std::get<CSSColor>(cssColor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <cxxreact/TraceSection.h>
#include <jsinspector-modern/tracing/PerformanceTracerSection.h>
#include <react/debug/react_native_assert.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/renderer/components/root/RootComponentDescriptor.h>
#include <react/renderer/core/LayoutContext.h>
#include <react/renderer/core/LayoutPrimitives.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <gtest/gtest.h>

#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#include <react/renderer/components/root/RootComponentDescriptor.h>
#include <react/renderer/components/scrollview/ScrollViewComponentDescriptor.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'canary',
},
enableAccumulatedUpdatesInRawPropsAndroid: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2024-12-10',
Expand Down Expand Up @@ -233,6 +234,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
enableCppPropsIteratorSetter: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2024-09-13',
Expand Down Expand Up @@ -287,6 +289,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
enableExclusivePropsUpdateAndroid: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2025-11-11',
Expand Down Expand Up @@ -517,6 +520,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
enableNativeCSSParsing: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2025-02-07',
Expand All @@ -538,6 +542,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
enablePropsUpdateReconciliationAndroid: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2024-07-12',
Expand Down Expand Up @@ -923,6 +928,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
useSharedAnimatedBackend: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2025-08-02',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import ReactNativeFeatureFlagsDefaultsH from './templates/common-cxx/ReactNative
import ReactNativeFeatureFlagsDynamicProviderH from './templates/common-cxx/ReactNativeFeatureFlagsDynamicProvider.h-template';
import ReactNativeFeatureFlagsOverrides from './templates/common-cxx/ReactNativeFeatureFlagsOverridesOSS_Stage_.h-template';
import ReactNativeFeatureFlagsProviderH from './templates/common-cxx/ReactNativeFeatureFlagsProvider.h-template';
import ReactNativePublicFeatureFlagsCPP from './templates/common-cxx/ReactNativePublicFeatureFlags.cpp-template';
import ReactNativePublicFeatureFlagsH from './templates/common-cxx/ReactNativePublicFeatureFlags.h-template';
import path from 'node:path';

export default function generateCommonCxxModules(
Expand All @@ -30,6 +32,10 @@ export default function generateCommonCxxModules(
ReactNativeFeatureFlagsH(featureFlagDefinitions),
[path.join(commonCxxPath, 'ReactNativeFeatureFlags.cpp')]:
ReactNativeFeatureFlagsCPP(featureFlagDefinitions),
[path.join(commonCxxPath, 'ReactNativePublicFeatureFlags.h')]:
ReactNativePublicFeatureFlagsH(featureFlagDefinitions),
[path.join(commonCxxPath, 'ReactNativePublicFeatureFlags.cpp')]:
ReactNativePublicFeatureFlagsCPP(featureFlagDefinitions),
[path.join(commonCxxPath, 'ReactNativeFeatureFlagsAccessor.h')]:
ReactNativeFeatureFlagsAccessorH(featureFlagDefinitions),
[path.join(commonCxxPath, 'ReactNativeFeatureFlagsAccessor.cpp')]:
Expand Down
13 changes: 12 additions & 1 deletion packages/react-native/scripts/featureflags/generateFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ export default function generateFiles(
...generatorConfig.featureFlagDefinitions,
common: Object.fromEntries(
Object.entries(generatorConfig.featureFlagDefinitions.common).filter(
([_, definition]) => !definition.skipNativeAPI,
([name, definition]) => {
if (
definition.skipNativeAPI &&
definition.dangerouslyExposeInPublicCppHeaders
) {
throw new Error(
`${name} cannot have both skipNativeAPI and dangerouslyExposeInPublicCppHeaders enabled at the same time.`,
);
}

return !definition.skipNativeAPI;
},
),
),
},
Expand Down
Loading
Loading