@@ -7,43 +7,47 @@ using namespace facebook;
77using namespace react ;
88
99void decorateRuntime (jsi::Runtime &runtime) {
10- auto isViewFlatteningDisabled = jsi::Function::createFromHostFunction (
11- runtime,
12- jsi::PropNameID::forAscii (runtime, " isViewFlatteningDisabled" ),
13- 1 ,
14- [](jsi::Runtime &runtime,
15- const jsi::Value &thisValue,
16- const jsi::Value *arguments,
17- size_t count) -> jsi::Value {
18- if (!arguments[0 ].isObject ()) {
19- return jsi::Value::null ();
20- }
21-
22- auto shadowNode = Bridging<std::shared_ptr<const ShadowNode>>::fromJs (
23- runtime, arguments[0 ]);
24-
25- bool isViewFlatteningDisabled = shadowNode->getTraits ().check (
26- ShadowNodeTraits::FormsStackingContext);
27-
28- // This is done using component names instead of type checking because
29- // of duplicate symbols for RN types, which prevent RTTI from working.
30- const char *componentName = shadowNode->getComponentName ();
31- bool isTextComponent = strcmp (componentName, " Paragraph" ) == 0 ||
32- strcmp (componentName, " Text" ) == 0 ;
33-
34- return jsi::Value (isViewFlatteningDisabled || isTextComponent);
35- });
36- runtime.global ().setProperty (
37- runtime, " isViewFlatteningDisabled" , std::move (isViewFlatteningDisabled));
10+ auto isViewFlatteningDisabled = jsi::Function::createFromHostFunction (
11+ runtime,
12+ jsi::PropNameID::forAscii (runtime, " isViewFlatteningDisabled" ),
13+ 1 ,
14+ [](jsi::Runtime &runtime,
15+ const jsi::Value &thisValue,
16+ const jsi::Value *arguments,
17+ size_t count) -> jsi::Value {
18+ if (!arguments[0 ].isObject ()) {
19+ return jsi::Value::null ();
20+ }
21+
22+ #if REACT_NATIVE_MINOR_VERSION >= 81
23+ auto shadowNode = Bridging<std::shared_ptr<const ShadowNode>>::fromJs (
24+ runtime, arguments[0 ]);
25+ #else
26+ auto shadowNode = shadowNodeFromValue (runtime, arguments[0 ]);
27+ #endif
28+
29+ bool isViewFlatteningDisabled = shadowNode->getTraits ().check (
30+ ShadowNodeTraits::FormsStackingContext);
31+
32+ // This is done using component names instead of type checking because
33+ // of duplicate symbols for RN types, which prevent RTTI from working.
34+ const char *componentName = shadowNode->getComponentName ();
35+ bool isTextComponent = strcmp (componentName, " Paragraph" ) == 0 ||
36+ strcmp (componentName, " Text" ) == 0 ;
37+
38+ return jsi::Value (isViewFlatteningDisabled || isTextComponent);
39+ });
40+ runtime.global ().setProperty (
41+ runtime, " isViewFlatteningDisabled" , std::move (isViewFlatteningDisabled));
3842}
3943
4044extern " C" JNIEXPORT void JNICALL
4145Java_com_swmansion_gesturehandler_react_RNGestureHandlerModule_decorateRuntime (
42- JNIEnv *env,
43- jobject clazz,
44- jlong jsiPtr) {
45- jsi::Runtime *runtime = reinterpret_cast <jsi::Runtime *>(jsiPtr);
46- if (runtime) {
47- decorateRuntime (*runtime);
48- }
46+ JNIEnv *env,
47+ jobject clazz,
48+ jlong jsiPtr) {
49+ jsi::Runtime *runtime = reinterpret_cast <jsi::Runtime *>(jsiPtr);
50+ if (runtime) {
51+ decorateRuntime (*runtime);
52+ }
4953}
0 commit comments