From 8dbcb2d0b9ba84e74329bca6b876801963c1df9b Mon Sep 17 00:00:00 2001 From: Yogev Ben David Date: Tue, 9 Mar 2021 08:50:13 +0200 Subject: [PATCH] Remove yellowBox observer on dealloc (#7015) This PR fixes a crash caused by a KVO observer that isn't cleared. Closes #7009 Co-authored-by: Yogev Ben David --- lib/ios/RNNComponentView.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ios/RNNComponentView.m b/lib/ios/RNNComponentView.m index 05f362001f3..3521eb9bfdb 100644 --- a/lib/ios/RNNComponentView.m +++ b/lib/ios/RNNComponentView.m @@ -44,6 +44,14 @@ - (void)observeValueForKeyPath:(NSString *)keyPath } } } + +- (void)dealloc { + if (_observeLayerChange) { + [self.subviews.firstObject.subviews.firstObject.layer removeObserver:self + forKeyPath:@"sublayers"]; + } +} + #endif @end