mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
feat: add initialProps property to RCTAppDelegate (#35848)
Summary: Hi there, While upgrading to 0.71 we realised the RCTAppDelegate doesn't offer a way to set custom `initProps` that would depend on `launchOptions`. This PR adds an `initialProps` property to the RCTAppDelegate. This would let us set this property based on `launchOptions` in our implementation of `didFinishLaunchingWithOptions` before calling `[super didFinishLaunchingWithOptions]` Thanks ! ## Changelog [IOS] [ADDED] - Add `initialProps` property to `RCTAppDelegate` Pull Request resolved: https://github.com/facebook/react-native/pull/35848 Reviewed By: rshest Differential Revision: D42543027 Pulled By: cipolleschi fbshipit-source-id: 55374914890445f8193c12a06a943b7796edb457
This commit is contained in:
committed by
Facebook GitHub Bot
parent
473eb1dd87
commit
b314e6f147
@@ -55,6 +55,7 @@
|
||||
@property (nonatomic, strong) UIWindow *window;
|
||||
@property (nonatomic, strong) RCTBridge *bridge;
|
||||
@property (nonatomic, strong) NSString *moduleName;
|
||||
@property (nonatomic, strong) NSDictionary *initialProps;
|
||||
|
||||
/**
|
||||
* It creates a `RCTBridge` using a delegate and some launch options.
|
||||
|
||||
@@ -84,7 +84,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
|
||||
|
||||
- (NSDictionary *)prepareInitialProps
|
||||
{
|
||||
NSMutableDictionary *initProps = [NSMutableDictionary new];
|
||||
NSMutableDictionary *initProps = self.initialProps ? [self.initialProps mutableCopy] : [NSMutableDictionary new];
|
||||
|
||||
#ifdef RCT_NEW_ARCH_ENABLED
|
||||
initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
self.moduleName = @"HelloWorld";
|
||||
// You can add your custom initial props in the dictionary below.
|
||||
// They will be passed down to the ViewController used by React Native.
|
||||
self.initialProps = @{};
|
||||
|
||||
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user