mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
2/3 Make interop WebView component Bridgeless compatible, and make uiManager addUIBlock migration easier
Summary:
Changelog: [iOS] Add `_viewRegistry_DEPRECATED addUIBlock` to replace `uiManager addUIBlock` for Fabric migration
Allow people to directly replace `uiManager addUIBlock` with `_viewRegistry_DEPRECATED addUIBlock` when they migrate the method in RCTViewManagers.
Currently we add an if check in the RCTViewManager, which makes migration a bit harder for OSS.
```
if (self.bridge) {
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
work();
}];
} else {
RCTExecuteOnMainQueue(work);
}
```
Reviewed By: sammy-SC
Differential Revision: D34532609
fbshipit-source-id: 19647fea03be8fd71d8f46dfe216275894d8165c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fc9dec9a35
commit
2c268d7fe6
@@ -437,6 +437,8 @@ typedef NSURL * (^RCTBridgelessBundleURLGetter)(void);
|
||||
|
||||
typedef UIView * (^RCTBridgelessComponentViewProvider)(NSNumber *);
|
||||
|
||||
typedef void (^RCTViewRegistryUIBlock)(RCTViewRegistry *viewRegistry);
|
||||
|
||||
/**
|
||||
* A class that allows NativeModules to query for views, given React Tags.
|
||||
*/
|
||||
@@ -445,6 +447,7 @@ typedef UIView * (^RCTBridgelessComponentViewProvider)(NSNumber *);
|
||||
- (void)setBridgelessComponentViewProvider:(RCTBridgelessComponentViewProvider)bridgelessComponentViewProvider;
|
||||
|
||||
- (UIView *)viewForReactTag:(NSNumber *)reactTag;
|
||||
- (void)addUIBlock:(RCTViewRegistryUIBlock)block;
|
||||
@end
|
||||
|
||||
typedef void (^RCTBridgelessJSModuleMethodInvoker)(
|
||||
|
||||
@@ -42,4 +42,28 @@
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)addUIBlock:(RCTViewRegistryUIBlock)block
|
||||
{
|
||||
if (!block) {
|
||||
return;
|
||||
}
|
||||
|
||||
__weak __typeof(self) weakSelf = self;
|
||||
if (_bridge) {
|
||||
[_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
__typeof(self) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
block(strongSelf);
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
RCTExecuteOnMainQueue(^{
|
||||
__typeof(self) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
block(strongSelf);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user