Skip to content

Commit 267fcf8

Browse files
authored
fix: building RN 0.79 and RN 0.80 - android (#377)
# Summary - fixes incorrect import for RN < 0.81 - fixes issue with serializing component props that affects initial input size measurements. Keep in mind, on RN 0.79 and RN 0.80 this might not work as precise as on newer versions, as we don't take into consideration `htmlStyle` - this is fine as RN 0.79 and RN 0.80 is no longer supported. We should officially drop support for them in the future and remove this code. - fixes: #369 ## Test Plan Provide **clear steps so another contributor can reproduce the behavior or verify the feature works**. For example: - Verify that app builds properly on RN 0.79 - Verify that app builds properly on RN 080 - Verify that app builds properly on RN 0.83 - Verify that on all of this versions initial component measurement is working correctly ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ❌ | | Android | ✅ |
1 parent 7662544 commit 267fcf8

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

android/src/main/new_arch/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ set(LIB_ANDROID_GENERATED_COMPONENTS_DIR ${LIB_ANDROID_GENERATED_JNI_DIR}/react/
1111
file(GLOB LIB_MODULE_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/${LIB_LITERAL}/*.cpp)
1212
file(GLOB LIB_CODEGEN_SRCS CONFIGURE_DEPENDS ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}/*.cpp)
1313

14+
if(NOT DEFINED REACT_NATIVE_MINOR_VERSION)
15+
set(REACT_NATIVE_MINOR_VERSION ${ReactAndroid_VERSION_MINOR})
16+
endif()
17+
18+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}")
19+
1420
add_library(
1521
${LIB_TARGET_NAME}
1622
SHARED

android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/conversions.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
#pragma once
22

33
#include <folly/dynamic.h>
4-
#include <react/renderer/components/FBReactNativeSpec/Props.h>
54
#include <react/renderer/components/RNEnrichedTextInputViewSpec/Props.h>
65
#include <react/renderer/core/propsConversions.h>
76

7+
#if REACT_NATIVE_MINOR_VERSION >= 81
8+
#include <react/renderer/components/FBReactNativeSpec/Props.h>
9+
#else
10+
#include <react/renderer/components/rncore/Props.h>
11+
#endif
12+
813
namespace facebook::react {
914

1015
#ifdef RN_SERIALIZABLE_STATE
@@ -21,6 +26,21 @@ inline folly::dynamic toDynamic(const EnrichedTextInputViewProps &props) {
2126

2227
return serializedProps;
2328
}
29+
#elif REACT_NATIVE_MINOR_VERSION >= 79
30+
inline folly::dynamic toDynamic(const EnrichedTextInputViewProps &props) {
31+
folly::dynamic serializedProps = folly::dynamic::object();
32+
serializedProps["defaultValue"] = props.defaultValue;
33+
serializedProps["placeholder"] = props.placeholder;
34+
serializedProps["fontSize"] = props.fontSize;
35+
serializedProps["fontWeight"] = props.fontWeight;
36+
serializedProps["fontStyle"] = props.fontStyle;
37+
serializedProps["fontFamily"] = props.fontFamily;
38+
// Ideally we should also serialize htmlStyle, but toDynamic function is not
39+
// generated in this RN version
40+
// As RN 0.79 and 0.80 is no longer supported, we can skip it for now
41+
42+
return serializedProps;
43+
}
2444
#endif
2545

2646
} // namespace facebook::react

0 commit comments

Comments
 (0)