1 // Copyright 2021-present 650 Industries. All rights reserved.
2 
3 #import <React/RCTComponent.h>
4 #import <React/RCTComponentData.h>
5 
6 typedef void (^RCTPropBlockAlias)(id<RCTComponent> _Nonnull view, id _Nullable json);
7 
8 @interface RCTComponentData (Privates)
9 
10 - (nonnull RCTPropBlockAlias)createPropBlock:(nonnull NSString *)name isShadowView:(BOOL)isShadowView;
11 
12 @end
13 
14 /**
15  This is a compatible adapter for Swift `ComponentData` to access react-native's `RCTComponentData`.
16  When running in react-native new architecture mode, the `eventDispatcher` is actually null.
17  however the`RCTComponentData` still expects it's nonnull because of the `NS_ASSUME_NONNULL_BEGIN`
18  https://github.com/facebook/react-native/blob/ea4724b37c9f78bd33daab547d6cc4f8b7f7dd81/packages/react-native/React/Views/RCTComponentData.h#L19-L35.
19  Swift will have a runtime exception from the implicitly unwrapping.
20  This compatible adapter basically allows the `eventDispatcher` to be nullable.
21  TODO: We should propose the fix to upstream and remove this adapter when dropping SDK 49.
22  */
23 @interface RCTComponentDataSwiftAdapter : RCTComponentData
24 
25 - (nonnull instancetype)initWithManagerClass:(nonnull Class)managerClass
26                                       bridge:(nonnull RCTBridge *)bridge
27                              eventDispatcher:(nullable id<RCTEventDispatcherProtocol>)eventDispatcher;
28 
29 @end
30