diff --git a/android/src/main/jni/cpp-adapter.cpp b/android/src/main/jni/cpp-adapter.cpp index 9fc57662f5..dc93e14ff3 100644 --- a/android/src/main/jni/cpp-adapter.cpp +++ b/android/src/main/jni/cpp-adapter.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include using namespace facebook; using namespace react; @@ -20,9 +22,15 @@ void decorateRuntime(jsi::Runtime &runtime) { } auto shadowNode = shadowNodeFromValue(runtime, arguments[0]); - bool isFormsStackingContext = shadowNode->getTraits().check(ShadowNodeTraits::FormsStackingContext); + bool isFormsStackingContext = shadowNode->getTraits().check( + ShadowNodeTraits::FormsStackingContext); - return jsi::Value(isFormsStackingContext); + // This is done using component names instead of type checking because of duplicate symbols for RN types, which prevent RTTI from working. + const char *componentName = shadowNode->getComponentName(); + bool isTextComponent = strcmp(componentName, "Paragraph") == 0 || + strcmp(componentName, "Text") == 0; + + return jsi::Value(isFormsStackingContext || isTextComponent); }); runtime.global().setProperty( runtime, "isFormsStackingContext", std::move(isFormsStackingContext)); @@ -30,11 +38,11 @@ void decorateRuntime(jsi::Runtime &runtime) { extern "C" JNIEXPORT void JNICALL Java_com_swmansion_gesturehandler_react_RNGestureHandlerModule_decorateRuntime( - JNIEnv *env, - jobject clazz, - jlong jsiPtr) { - jsi::Runtime *runtime = reinterpret_cast(jsiPtr); - if (runtime) { - decorateRuntime(*runtime); - } + JNIEnv *env, + jobject clazz, + jlong jsiPtr) { + jsi::Runtime *runtime = reinterpret_cast(jsiPtr); + if (runtime) { + decorateRuntime(*runtime); + } } diff --git a/apple/RNGestureHandlerModule.mm b/apple/RNGestureHandlerModule.mm index 4a0ce6939a..fbc194f884 100644 --- a/apple/RNGestureHandlerModule.mm +++ b/apple/RNGestureHandlerModule.mm @@ -14,6 +14,8 @@ #import #import +#import +#import #import #endif // RCT_NEW_ARCH_ENABLED @@ -100,7 +102,17 @@ void decorateRuntime(jsi::Runtime &runtime) return jsi::Value::null(); } auto shadowNode = shadowNodeFromValue(runtime, arguments[0]); + + if (dynamic_pointer_cast(shadowNode)) { + return jsi::Value(true); + } + + if (dynamic_pointer_cast(shadowNode)) { + return jsi::Value(true); + } + bool isFormsStackingContext = shadowNode->getTraits().check(ShadowNodeTraits::FormsStackingContext); + return jsi::Value(isFormsStackingContext); }); runtime.global().setProperty(runtime, "isFormsStackingContext", std::move(isFormsStackingContext));