From 201d2d1fdea42ccab1e040ef4424b37aed005613 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Thu, 14 Dec 2023 08:52:54 -0800 Subject: [PATCH] Unify SetProps for View and ShadowView in the InteropLayer (#41941) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41941 While working on the interop layer, I realized that htis code is duplicated. ## Changelog [Internal] - Use the same method for View And ShadowView in the Interop layer Reviewed By: sammy-SC Differential Revision: D51752171 fbshipit-source-id: 579652de262fea7edb13a1329cb07683eab78124 --- .../React/Views/RCTComponentData.m | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/react-native/React/Views/RCTComponentData.m b/packages/react-native/React/Views/RCTComponentData.m index 52efad6e159..db6f9711426 100644 --- a/packages/react-native/React/Views/RCTComponentData.m +++ b/packages/react-native/React/Views/RCTComponentData.m @@ -365,24 +365,23 @@ static RCTPropBlock createNSInvocationSetter(NSMethodSignature *typeSignature, S } - (void)setProps:(NSDictionary *)props forView:(id)view +{ + [self setProps:props forView:view isShadowView:NO]; +} + +- (void)setProps:(NSDictionary *)props forShadowView:(RCTShadowView *)shadowView +{ + [self setProps:props forView:shadowView isShadowView:YES]; +} + +- (void)setProps:(NSDictionary *)props forView:(id)view isShadowView:(BOOL)isShadowView { if (!view) { return; } [props enumerateKeysAndObjectsUsingBlock:^(NSString *key, id json, __unused BOOL *stop) { - [self propBlockForKey:key isShadowView:NO](view, json); - }]; -} - -- (void)setProps:(NSDictionary *)props forShadowView:(RCTShadowView *)shadowView -{ - if (!shadowView) { - return; - } - - [props enumerateKeysAndObjectsUsingBlock:^(NSString *key, id json, __unused BOOL *stop) { - [self propBlockForKey:key isShadowView:YES](shadowView, json); + [self propBlockForKey:key isShadowView:isShadowView](view, json); }]; }