Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load RNGestureHandlerModule lazily on iOS #3166

Merged
merged 2 commits into from Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions ios/native/NativeProxy.mm
Expand Up @@ -162,8 +162,12 @@ static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &v
scrollTo(viewTag, uiManager, x, y, animated);
};

id<RNGestureHandlerStateManager> gestureHandlerStateManager = [bridge moduleForName:@"RNGestureHandlerModule"];
auto setGestureStateFunction = [gestureHandlerStateManager](int handlerTag, int newState) {
id<RNGestureHandlerStateManager> gestureHandlerStateManager = nil;
auto setGestureStateFunction = [gestureHandlerStateManager, bridge](int handlerTag, int newState) mutable {
if (gestureHandlerStateManager == nil) {
gestureHandlerStateManager = [bridge moduleForName:@"RNGestureHandlerModule"];
}

setGestureState(gestureHandlerStateManager, handlerTag, newState);
};

Expand Down
9 changes: 0 additions & 9 deletions src/Animated.js
@@ -1,4 +1,3 @@
import { LogBox } from 'react-native';
import createAnimatedComponent from './createAnimatedComponent';
import {
addWhitelistedNativeProps,
Expand All @@ -21,11 +20,3 @@ const Animated = {
export * from './reanimated2';
export * from './reanimated1';
export default Animated;

// I think we can ignore this message as long as Gesture Handler doesn't
// try to load the Reanimated module. I figured it should be here instead of
// RNGH because this prevents the message from being displayed for all
// versions of RNGH.
LogBox.ignoreLogs([
'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
]);