From c4039a1f257ced3c9cf7ebde8c190618d535138f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bert?= <63123542+m-bert@users.noreply.github.com> Date: Thu, 1 Aug 2024 10:00:40 +0200 Subject: [PATCH] Fix build on RN 0.74 (#3024) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Changes made in #2966 were necessary for Gesture Handler to work with React Native 0.75. Unfortunately, they also broke builds on versions below 0.75. This PR fixes those builds. Fixes #3023 ## Test plan I've tested following scenarios: 1. New React Native 0.74.3 app without these changes - build fails 🔴 2. New React Native 0.74.3 app with this PR applied - builds properly 🟢 3. New React Native 0.75.0-rc.6 app with this PR applies - builds properly 🟢 --- android/src/main/jni/cpp-adapter.cpp | 6 ++---- apple/RNGestureHandlerModule.mm | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/android/src/main/jni/cpp-adapter.cpp b/android/src/main/jni/cpp-adapter.cpp index 4d4c6c7b00..9fc57662f5 100644 --- a/android/src/main/jni/cpp-adapter.cpp +++ b/android/src/main/jni/cpp-adapter.cpp @@ -19,10 +19,8 @@ void decorateRuntime(jsi::Runtime &runtime) { return jsi::Value::null(); } - auto shadowNodeWrapper = arguments[0] - .asObject(runtime).getNativeState(runtime); - bool isFormsStackingContext = shadowNodeWrapper->shadowNode->getTraits() - .check(ShadowNodeTraits::FormsStackingContext); + auto shadowNode = shadowNodeFromValue(runtime, arguments[0]); + bool isFormsStackingContext = shadowNode->getTraits().check(ShadowNodeTraits::FormsStackingContext); return jsi::Value(isFormsStackingContext); }); diff --git a/apple/RNGestureHandlerModule.mm b/apple/RNGestureHandlerModule.mm index 1e6fb0a105..4a0ce6939a 100644 --- a/apple/RNGestureHandlerModule.mm +++ b/apple/RNGestureHandlerModule.mm @@ -99,10 +99,8 @@ void decorateRuntime(jsi::Runtime &runtime) if (!arguments[0].isObject()) { return jsi::Value::null(); } - - auto shadowNodeWrapper = arguments[0].asObject(runtime).getNativeState(runtime); - bool isFormsStackingContext = - shadowNodeWrapper->shadowNode->getTraits().check(ShadowNodeTraits::FormsStackingContext); + auto shadowNode = shadowNodeFromValue(runtime, arguments[0]); + bool isFormsStackingContext = shadowNode->getTraits().check(ShadowNodeTraits::FormsStackingContext); return jsi::Value(isFormsStackingContext); }); runtime.global().setProperty(runtime, "isFormsStackingContext", std::move(isFormsStackingContext));