diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h index d45bcce07..a9be808e6 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h @@ -36,6 +36,15 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, strong, nullable) UIView *contentView; +/** + * Provides access to `nativeId` prop of the component. + * It might be used by subclasses (which need to refer to the view from + * other platform-specific external views or systems by some id) or + * by debugging/inspection tools. + * Defaults to `nil`. + */ +@property (nonatomic, strong, nullable) NSString *nativeId; + @end NS_ASSUME_NONNULL_END diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index a5f0c6728..dd8cb4df3 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -53,6 +53,11 @@ using namespace facebook::react; } // TODO: Implement all sutable non-layout props. + // `nativeId` + if (oldViewProps.nativeId != newViewProps.nativeId) { + self.nativeId = [NSString stringWithCString:newViewProps.nativeId.c_str() + encoding:NSASCIIStringEncoding]; + } } - (void)updateEventEmitter:(SharedEventEmitter)eventEmitter