|
9 | 9 |
|
10 | 10 | #import <React/RCTAssert.h>
|
11 | 11 | #import <React/RCTConversions.h>
|
| 12 | +#import <React/RCTLog.h> |
12 | 13 |
|
13 | 14 | #import <butter/map.h>
|
14 | 15 | #import <butter/set.h>
|
@@ -105,16 +106,21 @@ - (BOOL)registerComponentIfPossible:(std::string const &)name
|
105 | 106 | return YES;
|
106 | 107 | }
|
107 | 108 |
|
| 109 | + // Paper name: we prepare this variables to warn the user |
| 110 | + // when the component is registered in both Fabric and in the |
| 111 | + // interop layer, so they can remove that |
| 112 | + NSString *componentNameString = RCTNSStringFromString(name); |
| 113 | + BOOL isRegisteredInInteropLayer = [RCTLegacyViewManagerInteropComponentView isSupported:componentNameString]; |
| 114 | + |
108 | 115 | // Fallback 1: Call provider function for component view class.
|
109 | 116 | Class<RCTComponentViewProtocol> klass = RCTComponentViewClassWithName(name.c_str());
|
110 | 117 | if (klass) {
|
111 |
| - [self registerComponentViewClass:klass]; |
| 118 | + [self registerComponentViewClass:klass andWarnIfNeeded:isRegisteredInInteropLayer]; |
112 | 119 | return YES;
|
113 | 120 | }
|
114 | 121 |
|
115 | 122 | // Fallback 2: Try to use Paper Interop.
|
116 |
| - NSString *componentNameString = RCTNSStringFromString(name); |
117 |
| - if ([RCTLegacyViewManagerInteropComponentView isSupported:componentNameString]) { |
| 123 | + if (isRegisteredInInteropLayer) { |
118 | 124 | RCTLogNewArchitectureValidation(
|
119 | 125 | RCTNotAllowedInBridgeless,
|
120 | 126 | self,
|
@@ -203,4 +209,17 @@ - (RCTComponentViewDescriptor)createComponentViewWithComponentHandle:(facebook::
|
203 | 209 | return _providerRegistry.createComponentDescriptorRegistry(parameters);
|
204 | 210 | }
|
205 | 211 |
|
| 212 | +#pragma mark - Private |
| 213 | + |
| 214 | +- (void)registerComponentViewClass:(Class<RCTComponentViewProtocol>)componentViewClass |
| 215 | + andWarnIfNeeded:(BOOL)isRegisteredInInteropLayer |
| 216 | +{ |
| 217 | + [self registerComponentViewClass:componentViewClass]; |
| 218 | + if (isRegisteredInInteropLayer) { |
| 219 | + RCTLogWarn( |
| 220 | + @"Component with class %@ has been registered in both the New Architecture Renderer and in the Interop Layer.\nPlease remove it from the Interop Layer", |
| 221 | + componentViewClass); |
| 222 | + } |
| 223 | +} |
| 224 | + |
206 | 225 | @end
|
0 commit comments