From cde30eb6b7cce72ba8caa4d61b493f906dabc378 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Fri, 15 Jun 2018 11:25:22 -0700 Subject: [PATCH] Fabric: Basic implementation of Summary: Trivial. `nativeId` is meant to be used by subclasses of external inspector-like tools, so it does not have any real functionality. Reviewed By: fkgozali Differential Revision: D8344064 fbshipit-source-id: d86ef378cda1f7f0e9a7b4ffc09f51004ae530d2 --- .../Mounting/ComponentViews/View/RCTViewComponentView.h | 9 +++++++++ .../Mounting/ComponentViews/View/RCTViewComponentView.mm | 5 +++++ 2 files changed, 14 insertions(+) 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