diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index da56f236585..38ad88e8677 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -8,6 +8,8 @@ #import "RCTScrollViewComponentView.h" #import +#import +#import #import #import @@ -20,6 +22,21 @@ using namespace facebook::react; +static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteger tag) +{ + static uint16_t coalescingKey = 0; + RCTScrollEvent *scrollEvent = [[RCTScrollEvent alloc] initWithEventName:@"onScroll" + reactTag:[NSNumber numberWithInt:tag] + scrollViewContentOffset:scrollView.contentOffset + scrollViewContentInset:scrollView.contentInset + scrollViewContentSize:scrollView.contentSize + scrollViewFrame:scrollView.frame + scrollViewZoomScale:scrollView.zoomScale + userData:nil + coalescingKey:coalescingKey]; + [[RCTBridge currentBridge].eventDispatcher sendEvent:scrollEvent]; +} + @interface RCTScrollViewComponentView () @end @@ -211,6 +228,9 @@ using namespace facebook::react; if ((_lastScrollEventDispatchTime == 0) || (now - _lastScrollEventDispatchTime > _scrollEventThrottle)) { _lastScrollEventDispatchTime = now; std::static_pointer_cast(_eventEmitter)->onScroll([self _scrollViewMetrics]); + // Once Fabric implements proper NativeAnimationDriver, this should be removed. + // This is just a workaround to allow animations based on onScroll event. + RCTSendPaperScrollEvent_DEPRECATED(scrollView, self.tag); } } diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 6e65c034caf..3d73d7d52d9 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -335,7 +335,22 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation) - (NSString *)viewNameForReactTag:(NSNumber *)reactTag { RCTAssertUIManagerQueue(); - return _shadowViewRegistry[reactTag].viewName; + NSString *name = _shadowViewRegistry[reactTag].viewName; + if (name) { + return name; + } + + UIView *view = _viewRegistry[reactTag]; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundeclared-selector" + + if ([view respondsToSelector:@selector(componentViewName_DO_NOT_USE_THIS_IS_BROKEN)]) { + return [view performSelector:@selector(componentViewName_DO_NOT_USE_THIS_IS_BROKEN)]; + } + +#pragma clang diagnostic pop + return nil; } - (UIView *)viewForReactTag:(NSNumber *)reactTag