A framework for building native applications using React
feat: improve RCTAppDelegate usage for brownfield (#46625)
Summary:
This PR improves the usage of `RCTAppDelegate` for brownfield scenarios.
Currently, when we want to integrate React Native with a brownfield app users might not want to initialize React Native in the main window. They may want to create it later.
Example usage:
```swift
class AppDelegate: RCTAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Disable automatically creating react native window
self.automaticallyLoadReactNativeWindow = false
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
```
```swift
import Foundation
import React
import React_RCTAppDelegate
class SettingsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view = (RCTSharedApplication()?.delegate as? RCTAppDelegate)?.rootViewFactory .view(withModuleName: "Settings", initialProperties: [:])
}
}
```
## Changelog:
[IOS] [ADDED] - improve RCTAppDelegate usage for brownfield, add `automaticallyLoadReactNativeWindow` flag
Pull Request resolved: https://github.com/facebook/react-native/pull/46625
Test Plan: CI Green
Reviewed By: cortinico
Differential Revision: D63325397
Pulled By: cipolleschi
fbshipit-source-id: 1361bda5fcd91f4933219871c64a84a83c281c34 O
Oskar Kwaśniewski committed
391680fe844aad887e497912378c699aed13464b
Parent: 10a33e0
Committed by Facebook GitHub Bot <[email protected]>
on 9/26/2024, 12:39:01 PM