From f003b931b4bb37e6a8f05f2a5bca8df0d96e2d8a Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 17 Jul 2019 11:13:27 -0700 Subject: [PATCH] Fabric: Workaround in ScrollView that communicates the fact that the view was unmounted Summary: See the comment in the code. As part of proper fix of it, we also should remove a line in RCTScrollView that nulls the delegate. Reviewed By: mdvacca Differential Revision: D16296050 fbshipit-source-id: 54a4c6c60de4bd97c5cfb44652b5dc26852c540c --- .../ScrollView/RCTScrollViewComponentView.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 11afd9c13fa..990bba21294 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -169,6 +169,19 @@ using namespace facebook::react; }); } +- (void)prepareForRecycle +{ + // This is a temporary workaround. + // Some external libraries rely on that fact that UIScrollView instance inside React Native nulls its `delegate` when + // being unmounted. Here we are trying to mimic this behavior. + // See T47356757 for more details. + id delegate = _scrollView.delegate; + _scrollView.delegate = nil; + _scrollView.delegate = delegate; + _scrollView.contentOffset = CGPointZero; + [super prepareForRecycle]; +} + #pragma mark - UIScrollViewDelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView