mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Deprecate RedBox from RCTBridge to RCTModuleRegistry (#43717)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43717 As we are going to bridgeless in new architecture, we want to clean up the usage of RCTBridge to use RCTModuleRegistry to access NativeModule. Changelog: [iOS][Breaking] Remove `RCTRedBox` access through `RCTBridge` Reviewed By: philIip Differential Revision: D55532209 fbshipit-source-id: 62aa2a24b60ab54d7f3cf25c34beda4449aaeaed
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bf1a5d4934
commit
b5db214d2a
@@ -370,6 +370,9 @@ RCT_EXTERN_C_END
|
||||
- (id)moduleForName:(const char *)moduleName;
|
||||
- (id)moduleForName:(const char *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyLoad;
|
||||
- (BOOL)moduleIsInitialized:(Class)moduleClass;
|
||||
|
||||
// Note: This method lazily load the module as necessary.
|
||||
- (id)moduleForClass:(Class)moduleClass;
|
||||
@end
|
||||
|
||||
typedef UIView * (^RCTBridgelessComponentViewProvider)(NSNumber *);
|
||||
|
||||
@@ -64,4 +64,9 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id)moduleForClass:(Class)moduleClass
|
||||
{
|
||||
return [self moduleForName:RCTBridgeModuleNameForClass(moduleClass).UTF8String];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#import <React/RCTBridgeProxy.h>
|
||||
#import <React/RCTErrorCustomizer.h>
|
||||
|
||||
@class RCTJSStackFrame;
|
||||
@@ -48,19 +46,3 @@ typedef void (^RCTRedBoxButtonPressHandler)(void);
|
||||
@property (nonatomic, strong) dispatch_block_t overrideReloadAction;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* This category makes the red box instance available via the RCTBridge, which
|
||||
* is useful for any class that needs to access the red box or error log.
|
||||
*/
|
||||
@interface RCTBridge (RCTRedBox)
|
||||
|
||||
@property (nonatomic, readonly) RCTRedBox *redBox;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTBridgeProxy (RCTRedBox)
|
||||
|
||||
@property (nonatomic, readonly) RCTRedBox *redBox;
|
||||
|
||||
@end
|
||||
|
||||
@@ -8,14 +8,12 @@
|
||||
#import "RCTRedBox.h"
|
||||
|
||||
#import <FBReactNativeSpec/FBReactNativeSpec.h>
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTConvert.h>
|
||||
#import <React/RCTDefines.h>
|
||||
#import <React/RCTErrorInfo.h>
|
||||
#import <React/RCTEventDispatcherProtocol.h>
|
||||
#import <React/RCTJSStackFrame.h>
|
||||
#import <React/RCTRedBoxExtraDataViewController.h>
|
||||
#import <React/RCTRedBoxSetEnabled.h>
|
||||
#import <React/RCTReloadCommand.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
@@ -712,24 +710,6 @@ RCT_EXPORT_METHOD(dismiss)
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTBridge (RCTRedBox)
|
||||
|
||||
- (RCTRedBox *)redBox
|
||||
{
|
||||
return RCTRedBoxGetEnabled() ? [self moduleForClass:[RCTRedBox class]] : nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTBridgeProxy (RCTRedBox)
|
||||
|
||||
- (RCTRedBox *)redBox
|
||||
{
|
||||
return RCTRedBoxGetEnabled() ? [self moduleForClass:[RCTRedBox class]] : nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#else // Disabled
|
||||
|
||||
@interface RCTRedBox () <NativeRedBoxSpec>
|
||||
@@ -806,24 +786,6 @@ RCT_EXPORT_METHOD(dismiss)
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTBridge (RCTRedBox)
|
||||
|
||||
- (RCTRedBox *)redBox
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTBridgeProxy (RCTRedBox)
|
||||
|
||||
- (RCTRedBox *)redBox
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
Class RCTRedBoxCls(void)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#import <React/RCTPerformanceLogger.h>
|
||||
#import <React/RCTProfile.h>
|
||||
#import <React/RCTRedBox.h>
|
||||
#import <React/RCTRedBoxSetEnabled.h>
|
||||
#import <React/RCTReloadCommand.h>
|
||||
#import <React/RCTTurboModuleRegistry.h>
|
||||
#import <React/RCTUtils.h>
|
||||
@@ -1085,7 +1086,8 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
|
||||
if (self->_valid && !self->_loading) {
|
||||
if ([error userInfo][RCTJSRawStackTraceKey]) {
|
||||
[self.redBox showErrorMessage:[error localizedDescription] withRawStack:[error userInfo][RCTJSRawStackTraceKey]];
|
||||
RCTRedBox *redBox = RCTRedBoxGetEnabled() ? [self.moduleRegistry moduleForName:"RedBox"] : nil;
|
||||
[redBox showErrorMessage:[error localizedDescription] withRawStack:[error userInfo][RCTJSRawStackTraceKey]];
|
||||
}
|
||||
|
||||
RCTFatal(error);
|
||||
@@ -1100,7 +1102,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
|
||||
// Hack: once the bridge is invalidated below, it won't initialize any new native
|
||||
// modules. Initialize the redbox module now so we can still report this error.
|
||||
RCTRedBox *redBox = [self redBox];
|
||||
RCTRedBox *redBox = RCTRedBoxGetEnabled() ? [self.moduleRegistry moduleForName:"RedBox"] : nil;
|
||||
|
||||
_loading = NO;
|
||||
_valid = NO;
|
||||
|
||||
Reference in New Issue
Block a user