From 8d064d4fc0a60cd07e2b3edb38e6c4698000a452 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 29 Mar 2024 08:44:15 +0000 Subject: [PATCH] fix(js): make sure that RCTEventEmitter is registered before emitting the first onScroll event (#809) --- src/PagerView.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/PagerView.tsx b/src/PagerView.tsx index 9122b992..b8b1d5c2 100644 --- a/src/PagerView.tsx +++ b/src/PagerView.tsx @@ -14,6 +14,17 @@ import PagerViewView, { Commands as PagerViewCommands, } from './PagerViewNativeComponent'; +// The Fabric component for PagerView uses a work around present also in ScrollView: +// https://github.com/callstack/react-native-pager-view/blob/master/ios/Fabric/RNCPagerViewComponentView.mm#L362-L368 +// That workaround works only if we add these lines in to make sure that the RCTEventEmitter is registered properly +// in the JS callable modules. +// NOTE: This is a workaround as we would like to get rid of these lines below. But for the time being, as the cut date for +// 0.74 approaches, we need to keep these lines. +// As soon as we figure out how to move forward, we will provide guidance and/or submit a PR to fix this. +if (Platform.OS === 'ios') { + require('react-native/Libraries/Renderer/shims/ReactNative'); // Force side effects to prevent T55744311 +} + /** * Container that allows to flip left and right between child views. Each * child view of the `PagerView` will be treated as a separate page