Attempt to fix undefined instance handle in EventTarget

Summary:
changelog: [internal]

Completion block can retain `_eventEmitter` beyond existence of the component. To fix this, do not retain `_eventEmitter` by block but try to acquire it inside it.

Reviewed By: JoshuaGross

Differential Revision: D29969189

fbshipit-source-id: 456c42f816acc160f9d6bbd3f9c8c55d611940b2
This commit is contained in:
Samuel Susla
2021-07-28 14:45:12 -07:00
committed by Facebook GitHub Bot
parent dc8d218077
commit f592ad0509
@@ -171,12 +171,11 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
UIView *snapshot = _modalContentsSnapshot;
[self.viewController.view addSubview:snapshot];
auto eventEmitter = [self modalEventEmitter];
[self dismissViewController:self.viewController
animated:_shouldAnimatePresentation
completion:^{
[snapshot removeFromSuperview];
auto eventEmitter = [self modalEventEmitter];
if (eventEmitter) {
eventEmitter->onDismiss(ModalHostViewEventEmitter::OnDismiss{});
}