Skip to content

Commit 4099a15

Browse files
committed
change(ios): make root VC notify on viewDidAppear/-Disappear
1 parent 3c03d8e commit 4099a15

4 files changed

Lines changed: 50 additions & 3 deletions

File tree

packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#import "RCTDefaultReactNativeFactoryDelegate.h"
99
#import <ReactCommon/RCTHost.h>
10+
#import <React/RCTViewController.h>
1011
#import "RCTAppSetupUtils.h"
1112
#import "RCTDependencyProvider.h"
1213
#if USE_THIRD_PARTY_JSC != 1
@@ -28,7 +29,7 @@ - (NSURL *_Nullable)sourceURLForBridge:(nonnull RCTBridge *)bridge
2829

2930
- (UIViewController *)createRootViewController
3031
{
31-
return [UIViewController new];
32+
return [RCTViewController new];
3233
}
3334

3435
- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary *)launchOptions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
9+
#import <UIKit/UIKit.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface RCTViewController : UIViewController
14+
15+
@end
16+
17+
NS_ASSUME_NONNULL_END
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// RCTViewController.m
3+
// React-Core
4+
//
5+
// Created by Hanno Goedecke on 27.04.26.
6+
//
7+
8+
#import "RCTViewController.h"
9+
#import <React/UIViewController+React.h>
10+
11+
@interface RCTViewController ()
12+
13+
@end
14+
15+
@implementation RCTViewController
16+
17+
- (void)viewDidAppear:(BOOL)animated
18+
{
19+
[super viewDidAppear:animated];
20+
[self reactNotifyViewControllerDidAppear:animated];
21+
}
22+
23+
- (void)viewDidDisappear:(BOOL)animated
24+
{
25+
[super viewDidDisappear:animated];
26+
[self reactNotifyViewControllerDidDisappear:animated];
27+
}
28+
29+
@end

packages/react-native/React/Views/RCTWrapperViewController.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#import <UIKit/UIKit.h>
8+
#import <React/RCTViewController.h>
99

1010
@class RCTWrapperViewController;
1111

12-
@interface RCTWrapperViewController : UIViewController
12+
@interface RCTWrapperViewController : RCTViewController
1313

1414
- (instancetype)initWithContentView:(UIView *)contentView NS_DESIGNATED_INITIALIZER;
1515

0 commit comments

Comments
 (0)