mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Remove RCTUnsafeExecuteOnMainQueueSync from sample modules (#50149)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50149 Let's just remove RCTUnsafeExecuteOnMainQueueSync from the examples. That way, people don't copy-paste it, thinking it's okay to use. Changelog: [Internal] Reviewed By: lyahdav Differential Revision: D71505823 fbshipit-source-id: f8d51b1a16bfdd6abdf62a6ba09ffff49d79a3f1
This commit is contained in:
1 parent
81dfaad871
commit
45fa563d3a
3 files changed
+32
-27
No files matched your search
+5
-10
@@ -39,16 +39,11 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (NSDictionary *)getConstants
|
||||
{
|
||||
__block NSDictionary *constants;
|
||||
RCTUnsafeExecuteOnMainQueueSync(^{
|
||||
constants = @{
|
||||
@"const1" : @YES,
|
||||
@"const2" : @(390),
|
||||
@"const3" : @"something",
|
||||
};
|
||||
});
|
||||
|
||||
return constants;
|
||||
return @{
|
||||
@"const1" : @YES,
|
||||
@"const2" : @(390),
|
||||
@"const3" : @"something",
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Remove once fully migrated to TurboModule.
|
||||
|
||||
+18
-15
@@ -9,16 +9,19 @@
|
||||
#import "RCTSampleTurboModulePlugin.h"
|
||||
|
||||
#import <React/RCTAssert.h>
|
||||
#import <React/RCTInitializing.h>
|
||||
#import <React/RCTUtils.h>
|
||||
#import <ReactCommon/RCTTurboModuleWithJSIBindings.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
@interface RCTSampleTurboModule () <RCTTurboModuleWithJSIBindings>
|
||||
@interface RCTSampleTurboModule () <RCTTurboModuleWithJSIBindings, RCTInitializing>
|
||||
@end
|
||||
|
||||
@implementation RCTSampleTurboModule
|
||||
@implementation RCTSampleTurboModule {
|
||||
NSDictionary *_constants;
|
||||
}
|
||||
|
||||
// Backward-compatible export
|
||||
RCT_EXPORT_MODULE()
|
||||
@@ -29,6 +32,18 @@ RCT_EXPORT_MODULE()
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
UIScreen *mainScreen = UIScreen.mainScreen;
|
||||
CGSize screenSize = mainScreen.bounds.size;
|
||||
|
||||
_constants = @{
|
||||
@"const1" : @YES,
|
||||
@"const2" : @(screenSize.width),
|
||||
@"const3" : @"something",
|
||||
};
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
{
|
||||
return dispatch_get_main_queue();
|
||||
@@ -49,19 +64,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (NSDictionary *)getConstants
|
||||
{
|
||||
__block NSDictionary *constants;
|
||||
RCTUnsafeExecuteOnMainQueueSync(^{
|
||||
UIScreen *mainScreen = UIScreen.mainScreen;
|
||||
CGSize screenSize = mainScreen.bounds.size;
|
||||
|
||||
constants = @{
|
||||
@"const1" : @YES,
|
||||
@"const2" : @(screenSize.width),
|
||||
@"const3" : @"something",
|
||||
};
|
||||
});
|
||||
|
||||
return constants;
|
||||
return _constants;
|
||||
}
|
||||
|
||||
// TODO: Remove once fully migrated to TurboModule.
|
||||
|
||||
@@ -44,8 +44,15 @@
|
||||
"javaPackageName": "com.facebook.fbreact.specs"
|
||||
},
|
||||
"ios": {
|
||||
"componentProvider": {
|
||||
"RNTMyNativeView": "RNTMyNativeViewComponentView"
|
||||
"modules": {
|
||||
"SampleTurboModule": {
|
||||
"unstableRequiresMainQueueSetup": true
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"RNTMyNativeView": {
|
||||
"className": "RNTMyNativeViewComponentView"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user