From de39a204c3588a3c02dc2e72464174c75b3a6749 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 13 Sep 2024 08:10:10 -0700 Subject: [PATCH] Fix SVC Validator for Box Shadow and filter (#46454) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46454 The SVC Validator have no idea on how to process a simple NSArray *. With this change, we are creating two named types for the NSArray: * BoxShadowArray * FilterArray To create unique types that we can reference in JS. We are then enhancing the `getProcessor` function to return the proper processor when those types are found in the NativeViewConfig ## Changelog: [iOS][Fixed] - Fixed warnings when validating SVC ## Facebook: This change is OTA safe: even when we ship the JS before the native code, the new cases in the switch will be never hit, similarly to the situation we have right now. As soon as the native code is shipped, the new cases will start get hit and the wrning will disappear Reviewed By: NickGerleman Differential Revision: D62574612 fbshipit-source-id: d173bf5534ee5e436f23a4bc6e2fb25e72a4b06d --- .../getNativeComponentAttributes.js | 4 ++++ .../react-native/React/Views/RCTViewManager.m | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js b/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js index 232cbc91487..2af83f4c4e5 100644 --- a/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js +++ b/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js @@ -188,6 +188,10 @@ function getProcessorForType(typeName: string): ?(nextProp: any) => any { case 'UIImage': case 'RCTImageSource': return resolveAssetSource; + case 'BoxShadowArray': + return processBoxShadow; + case 'FilterArray': + return processFilter; // Android Types case 'Color': return processColor; diff --git a/packages/react-native/React/Views/RCTViewManager.m b/packages/react-native/React/Views/RCTViewManager.m index 104859964ac..368e499e23d 100644 --- a/packages/react-native/React/Views/RCTViewManager.m +++ b/packages/react-native/React/Views/RCTViewManager.m @@ -431,18 +431,19 @@ RCT_CUSTOM_VIEW_PROPERTY(experimental_layoutConformance, NSString *, RCTView) // filtered by view configs. } -RCT_CUSTOM_VIEW_PROPERTY(filter, NSArray *, RCTView) +typedef NSArray *FilterArray; // Custom type to make the StaticViewConfigValidator Happy +RCT_CUSTOM_VIEW_PROPERTY(filter, FilterArray, RCTView) { - // Property is only to be used in the new renderer. - // It is necessary to add it here, otherwise it gets - // filtered by view configs. + // Property is only to be used in the new renderer. + // It is necessary to add it here, otherwise it gets + // filtered by view configs. } - -RCT_CUSTOM_VIEW_PROPERTY(boxShadow, NSArray *, RCTView) +typedef NSArray *BoxShadowArray; // Custom type to make the StaticViewConfigValidator Happy +RCT_CUSTOM_VIEW_PROPERTY(boxShadow, BoxShadowArray, RCTView) { - // Property is only to be used in the new renderer. - // It is necessary to add it here, otherwise it gets - // filtered by view configs. + // Property is only to be used in the new renderer. + // It is necessary to add it here, otherwise it gets + // filtered by view configs. } RCT_CUSTOM_VIEW_PROPERTY(experimental_mixBlendMode, NSString *, RCTView)