Skip to content

Commit 801acd8

Browse files
committed
Continuously check whether ui runtime was decorated
1 parent 0454c96 commit 801acd8

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
6161
override fun createGestureHandler(handlerName: String, handlerTagDouble: Double, config: ReadableMap) {
6262
if (ReanimatedProxy.REANIMATED_INSTALLED && !uiRuntimeDecorated) {
6363
uiRuntimeDecorated = decorateUIRuntime()
64-
if (!uiRuntimeDecorated) {
65-
throw Exception("Failed to decorate UI runtime")
66-
}
6764
}
6865

6966
val handlerTag = handlerTagDouble.toInt()

packages/react-native-gesture-handler/apple/RNGestureHandlerModule.mm

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ @implementation RNGestureHandlerModule {
5353
NSMutableArray<GestureHandlerOperation> *_operations;
5454

5555
jsi::Runtime *_rnRuntime;
56-
bool _triedToDecorateUIRuntime;
56+
57+
bool _checkedReanimated;
58+
bool _reanimatedAvailable;
59+
bool _uiRuntimeDecorated;
5760
}
5861

5962
#ifdef RCT_NEW_ARCH_ENABLED
@@ -145,15 +148,12 @@ - (bool)installUIRuntimeBindings
145148
: (double)handlerTag config
146149
: (NSDictionary *)config)
147150
{
148-
if (!_triedToDecorateUIRuntime) {
149-
_triedToDecorateUIRuntime = true;
150-
bool reanimatedAvailable = [self.moduleRegistry moduleForName:"ReanimatedModule"] != nil;
151-
152-
if (reanimatedAvailable && ![self installUIRuntimeBindings]) {
153-
@throw [[NSException alloc] initWithName:@"RNGHRuntimeDecorationException"
154-
reason:@"Failed to decorate UI runtime"
155-
userInfo:nil];
156-
}
151+
if (!_checkedReanimated) {
152+
_reanimatedAvailable = [self.moduleRegistry moduleForName:"ReanimatedModule"] != nil;
153+
}
154+
155+
if (_reanimatedAvailable && !_uiRuntimeDecorated) {
156+
_uiRuntimeDecorated = [self installUIRuntimeBindings];
157157
}
158158

159159
[self addOperationBlock:^(RNGestureHandlerManager *manager) {

0 commit comments

Comments
 (0)