Skip to content

Commit 6490f61

Browse files
committed
🐞 Minor Bugfix: Modal
Summary: Fixed modal contents flashing in when presented (i.e init modal when modal contents has been mounted)
1 parent 83b7b07 commit 6490f61

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ PODS:
182182
- React-cxxreact (= 0.62.2)
183183
- React-jsi (= 0.62.2)
184184
- React-jsinspector (0.62.2)
185-
- react-native-ios-modal (0.1.6):
185+
- react-native-ios-modal (0.1.7):
186186
- React
187187
- React-RCTActionSheet (0.62.2):
188188
- React-Core/RCTActionSheetHeaders (= 0.62.2)
@@ -350,7 +350,7 @@ SPEC CHECKSUMS:
350350
React-jsi: b6dc94a6a12ff98e8877287a0b7620d365201161
351351
React-jsiexecutor: 1540d1c01bb493ae3124ed83351b1b6a155db7da
352352
React-jsinspector: 512e560d0e985d0e8c479a54a4e5c147a9c83493
353-
react-native-ios-modal: 292609c6ae163b2d28baa8af356ab1b43fe6b40a
353+
react-native-ios-modal: 5dd74c818c53e1a6679eec89f6925b18c155dd87
354354
React-RCTActionSheet: f41ea8a811aac770e0cc6e0ad6b270c644ea8b7c
355355
React-RCTAnimation: 49ab98b1c1ff4445148b72a3d61554138565bad0
356356
React-RCTBlob: a332773f0ebc413a0ce85942a55b064471587a71

ios/src_library/React Native/RCTModalView/RCTModalView.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ class RCTModalView: UIView {
285285
self.reactSubview = subview;
286286
self.touchHandler.attach(to: subview);
287287

288-
self.modalVC?.reactView = reactSubview;
288+
// modal contents has been mounted, and is about to be presented so
289+
// prepare for modal presentation and init the vc's
290+
self.initControllers();
289291
};
290292

291293
override func removeReactSubview(_ subview: UIView!) {
@@ -300,9 +302,11 @@ class RCTModalView: UIView {
300302
print("RCTModalView, removeReactSubview - for reactTag: \(self.reactTag ?? -1)");
301303
#endif
302304

305+
// modal contents has been unmounted so reset react subview
303306
self.reactSubview = nil;
304307
self.modalVC?.reactView = nil;
305308
self.touchHandler.detach(from: subview);
309+
self.deinitControllers();
306310
};
307311

308312
};
@@ -316,11 +320,6 @@ extension RCTModalView {
316320
public func presentModal(completion: completionResult = nil) {
317321
let hasWindow: Bool = (self.window != nil);
318322

319-
/// this view is going to be rendered, so we should init the controllers
320-
if self.modalVC == nil || self.modalNVC == nil {
321-
self.initControllers();
322-
};
323-
324323
guard (hasWindow && !self.isPresented),
325324
let modalNVC = self.modalNVC,
326325
let (index, topMostPresentedVC) = self.getTopMostPresentedVC()

0 commit comments

Comments
 (0)