Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RNTester AppDelegate for changes made to SurfacePresenter API #28580

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions RNTester/RNTester/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@

#ifdef RN_FABRIC_ENABLED
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>

#import <react/config/ReactNativeConfig.h>
#endif


Expand All @@ -53,7 +56,9 @@
@interface AppDelegate() <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate>{

#ifdef RN_FABRIC_ENABLED
RCTSurfacePresenter *_surfacePresenter;
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
facebook::react::ContextContainer::Shared _contextContainer;
#endif

RCTTurboModuleManager *_turboModuleManager;
Expand All @@ -77,14 +82,15 @@ - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWith
}

#ifdef RN_FABRIC_ENABLED
_surfacePresenter = [[RCTSurfacePresenter alloc] initWithBridge:_bridge
config:nil
imageLoader:RCTTurboModuleEnabled() ?
[_bridge moduleForName:@"RCTImageLoader"
lazilyLoadIfNecessary:YES] : nil
runtimeExecutor:nullptr];

_bridge.surfacePresenter = _surfacePresenter;
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();

_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);

_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:_bridge
contextContainer:_contextContainer];

_bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;

UIView *rootView = [[RCTFabricSurfaceHostingProxyRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps];
#else
Expand Down