diff --git a/.changeset/loud-coins-deny.md b/.changeset/loud-coins-deny.md new file mode 100644 index 0000000000..6c62848ba9 --- /dev/null +++ b/.changeset/loud-coins-deny.md @@ -0,0 +1,6 @@ +--- +"@rnx-kit/react-native-host": patch +--- + +Backport fix for shadow node state not updating (see +https://github.com/facebook/react-native/issues/49694) diff --git a/packages/react-native-host/cocoa/RNXBridgelessHeaders.h b/packages/react-native-host/cocoa/RNXBridgelessHeaders.h index 550ad9aa3f..0f5de45fff 100644 --- a/packages/react-native-host/cocoa/RNXBridgelessHeaders.h +++ b/packages/react-native-host/cocoa/RNXBridgelessHeaders.h @@ -1,5 +1,9 @@ #if USE_BRIDGELESS +// clang-format off +#import "RNXFeatureMacros.h" +// clang-format on + #import #import #import @@ -10,22 +14,19 @@ #import #endif // USE_HERMES -#if __has_include() +#ifdef USE_REACT_NATIVE_CONFIG #import -#define USE_REACT_NATIVE_CONFIG -#endif // __has_include() +#endif // USE_REACT_NATIVE_CONFIG -#if __has_include() +#ifdef USE_FEATURE_FLAGS #import #import -#define USE_FEATURE_FLAGS -#endif // __has_include() +#endif // USE_FEATURE_FLAGS -#if __has_include() -#define USE_CODEGEN_PROVIDER 1 +#ifdef USE_CODEGEN_PROVIDER #import #import -#endif // __has_include() +#endif // USE_CODEGEN_PROVIDER #if __has_include() using SharedJSRuntimeFactory = std::shared_ptr; @@ -58,9 +59,6 @@ using SharedJSRuntimeFactory = std::shared_ptr) || __has_include() -#define USE_UNIFIED_FEATURE_FLAGS 1 -#endif // __has_include() // https://github.com/facebook/react-native/blob/0.74-stable/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm#L272-L286 class RNXBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults @@ -83,12 +81,22 @@ class RNXBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlag { return true; } -#if !__has_include() && !__has_include() // 0.77 +#if USE_VIEW_COMMAND_RACE_FIX // 0.77 bool enableFixForViewCommandRace() override { return true; } -#endif // 0.77 +#endif // USE_VIEW_COMMAND_RACE_FIX +#if USE_UPDATE_RUNTIME_SHADOW_NODE_REFS_ON_COMMIT // >= 0.79 + bool updateRuntimeShadowNodeReferencesOnCommit() override + { + return true; + } + bool useShadowNodeStateOnClone() override + { + return true; + } +#endif // USE_UPDATE_RUNTIME_SHADOW_NODE_REFS_ON_COMMIT #else // < 0.77 bool useModernRuntimeScheduler() override { diff --git a/packages/react-native-host/cocoa/RNXFeatureMacros.h b/packages/react-native-host/cocoa/RNXFeatureMacros.h new file mode 100644 index 0000000000..acc3690018 --- /dev/null +++ b/packages/react-native-host/cocoa/RNXFeatureMacros.h @@ -0,0 +1,31 @@ +#if USE_BRIDGELESS + +#if __has_include() +#define USE_REACT_NATIVE_CONFIG 1 +#endif // __has_include() + +#if __has_include() +#define USE_FEATURE_FLAGS 1 +#endif // __has_include() + +#if __has_include() +#define USE_CODEGEN_PROVIDER 1 +#endif // __has_include() + +#ifdef USE_FEATURE_FLAGS + +#if __has_include() || __has_include() +#define USE_UNIFIED_FEATURE_FLAGS 1 +#endif // __has_include() + +#if !__has_include() && !__has_include() +#define USE_VIEW_COMMAND_RACE_FIX 1 +#endif // !__has_include() + +#if __has_include() || __has_include() +#define USE_UPDATE_RUNTIME_SHADOW_NODE_REFS_ON_COMMIT 1 +#endif // __has_include() + +#endif // USE_FEATURE_FLAGS + +#endif // USE_BRIDGELESS