File tree 5 files changed +12
-58
lines changed
packages/react-native/React
5 files changed +12
-58
lines changed Original file line number Diff line number Diff line change @@ -370,6 +370,9 @@ RCT_EXTERN_C_END
370
370
- (id )moduleForName : (const char *)moduleName ;
371
371
- (id )moduleForName : (const char *)moduleName lazilyLoadIfNecessary : (BOOL )lazilyLoad ;
372
372
- (BOOL )moduleIsInitialized : (Class )moduleClass ;
373
+
374
+ // Note: This method lazily load the module as necessary.
375
+ - (id )moduleForClass : (Class )moduleClass ;
373
376
@end
374
377
375
378
typedef UIView * (^RCTBridgelessComponentViewProvider)(NSNumber *);
Original file line number Diff line number Diff line change @@ -64,4 +64,9 @@ - (BOOL)moduleIsInitialized:(Class)moduleClass
64
64
return NO ;
65
65
}
66
66
67
+ - (id )moduleForClass : (Class )moduleClass
68
+ {
69
+ return [self moduleForName: RCTBridgeModuleNameForClass (moduleClass).UTF8String];
70
+ }
71
+
67
72
@end
Original file line number Diff line number Diff line change 7
7
8
8
#import < UIKit/UIKit.h>
9
9
10
- #import < React/RCTBridge.h>
11
10
#import < React/RCTBridgeModule.h>
12
- #import < React/RCTBridgeProxy.h>
13
11
#import < React/RCTErrorCustomizer.h>
14
12
15
13
@class RCTJSStackFrame;
@@ -48,19 +46,3 @@ typedef void (^RCTRedBoxButtonPressHandler)(void);
48
46
@property (nonatomic , strong ) dispatch_block_t overrideReloadAction;
49
47
50
48
@end
51
-
52
- /* *
53
- * This category makes the red box instance available via the RCTBridge, which
54
- * is useful for any class that needs to access the red box or error log.
55
- */
56
- @interface RCTBridge (RCTRedBox)
57
-
58
- @property (nonatomic , readonly ) RCTRedBox *redBox;
59
-
60
- @end
61
-
62
- @interface RCTBridgeProxy (RCTRedBox)
63
-
64
- @property (nonatomic , readonly ) RCTRedBox *redBox;
65
-
66
- @end
Original file line number Diff line number Diff line change 8
8
#import " RCTRedBox.h"
9
9
10
10
#import < FBReactNativeSpec/FBReactNativeSpec.h>
11
- #import < React/RCTBridge.h>
12
11
#import < React/RCTConvert.h>
13
12
#import < React/RCTDefines.h>
14
13
#import < React/RCTErrorInfo.h>
15
14
#import < React/RCTEventDispatcherProtocol.h>
16
15
#import < React/RCTJSStackFrame.h>
17
16
#import < React/RCTRedBoxExtraDataViewController.h>
18
- #import < React/RCTRedBoxSetEnabled.h>
19
17
#import < React/RCTReloadCommand.h>
20
18
#import < React/RCTUtils.h>
21
19
@@ -712,24 +710,6 @@ - (void)addCustomButton:(NSString *)title onPressHandler:(RCTRedBoxButtonPressHa
712
710
713
711
@end
714
712
715
- @implementation RCTBridge (RCTRedBox)
716
-
717
- - (RCTRedBox *)redBox
718
- {
719
- return RCTRedBoxGetEnabled () ? [self moduleForClass: [RCTRedBox class ]] : nil ;
720
- }
721
-
722
- @end
723
-
724
- @implementation RCTBridgeProxy (RCTRedBox)
725
-
726
- - (RCTRedBox *)redBox
727
- {
728
- return RCTRedBoxGetEnabled () ? [self moduleForClass: [RCTRedBox class ]] : nil ;
729
- }
730
-
731
- @end
732
-
733
713
#else // Disabled
734
714
735
715
@interface RCTRedBox () <NativeRedBoxSpec>
@@ -806,24 +786,6 @@ - (void)addCustomButton:(NSString *)title onPressHandler:(RCTRedBoxButtonPressHa
806
786
807
787
@end
808
788
809
- @implementation RCTBridge (RCTRedBox)
810
-
811
- - (RCTRedBox *)redBox
812
- {
813
- return nil ;
814
- }
815
-
816
- @end
817
-
818
- @implementation RCTBridgeProxy (RCTRedBox)
819
-
820
- - (RCTRedBox *)redBox
821
- {
822
- return nil ;
823
- }
824
-
825
- @end
826
-
827
789
#endif
828
790
829
791
Class RCTRedBoxCls (void )
Original file line number Diff line number Diff line change 29
29
#import < React/RCTPerformanceLogger.h>
30
30
#import < React/RCTProfile.h>
31
31
#import < React/RCTRedBox.h>
32
+ #import < React/RCTRedBoxSetEnabled.h>
32
33
#import < React/RCTReloadCommand.h>
33
34
#import < React/RCTTurboModuleRegistry.h>
34
35
#import < React/RCTUtils.h>
@@ -1085,7 +1086,8 @@ - (void)handleError:(NSError *)error
1085
1086
1086
1087
if (self->_valid && !self->_loading ) {
1087
1088
if ([error userInfo ][RCTJSRawStackTraceKey]) {
1088
- [self .redBox showErrorMessage: [error localizedDescription ] withRawStack: [error userInfo ][RCTJSRawStackTraceKey]];
1089
+ RCTRedBox *redBox = RCTRedBoxGetEnabled () ? [self .moduleRegistry moduleForName: " RedBox" ] : nil ;
1090
+ [redBox showErrorMessage: [error localizedDescription ] withRawStack: [error userInfo ][RCTJSRawStackTraceKey]];
1089
1091
}
1090
1092
1091
1093
RCTFatal (error);
@@ -1100,7 +1102,7 @@ - (void)handleError:(NSError *)error
1100
1102
1101
1103
// Hack: once the bridge is invalidated below, it won't initialize any new native
1102
1104
// modules. Initialize the redbox module now so we can still report this error.
1103
- RCTRedBox *redBox = [self redBox ] ;
1105
+ RCTRedBox *redBox = RCTRedBoxGetEnabled () ? [self .moduleRegistry moduleForName: " RedBox " ] : nil ;
1104
1106
1105
1107
_loading = NO ;
1106
1108
_valid = NO ;
You can’t perform that action at this time.
0 commit comments