Skip to content

Commit f109730

Browse files
authored
fix: android - crashes during component destructing (#205)
See: [RN changelog](https://github.com/facebook/react-native/blob/535efc1403e53bde190ce5ddb7ecf97918c5e5fd/CHANGELOG.md?plain=1#L277) Fixes: #198
1 parent c0399f8 commit f109730

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

android/src/main/new_arch/CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ target_link_libraries(
3939
ReactAndroid::reactnative
4040
)
4141

42-
target_compile_options(
43-
${LIB_TARGET_NAME}
44-
PRIVATE
45-
-DLOG_TAG=\"ReactNative\"
46-
-fexceptions
47-
-frtti
48-
-Wall
49-
-std=c++20
50-
)
42+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
43+
target_compile_reactnative_options(${LIB_TARGET_NAME} PRIVATE)
44+
else()
45+
target_compile_options(
46+
${LIB_TARGET_NAME}
47+
PRIVATE
48+
-DLOG_TAG=\"ReactNative\"
49+
-fexceptions
50+
-frtti
51+
-Wall
52+
-std=c++20
53+
)
54+
endif()
5155

5256
target_include_directories(
5357
${CMAKE_PROJECT_NAME}

example/src/App.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ export default function App() {
8080
const [currentLink, setCurrentLink] =
8181
useState<CurrentLinkState>(DEFAULT_LINK_STATE);
8282

83+
const [key, setKey] = useState(0);
84+
const incrementKey = () => setKey((v) => v + 1);
85+
const collectGarbage = () => global.gc?.();
86+
8387
const ref = useRef<EnrichedTextInputInstance>(null);
8488

8589
const userMention = useUserMention();
@@ -259,6 +263,7 @@ export default function App() {
259263
<Text style={styles.label}>Enriched Text Input</Text>
260264
<View style={styles.editor}>
261265
<EnrichedTextInput
266+
key={key}
262267
autoFocus
263268
ref={ref}
264269
mentionIndicators={['@', '#']}
@@ -295,6 +300,14 @@ export default function App() {
295300
<Button title="Focus" onPress={handleFocus} style={styles.button} />
296301
<Button title="Blur" onPress={handleBlur} style={styles.button} />
297302
</View>
303+
<View style={styles.buttonStack}>
304+
<Button
305+
title="Bump key"
306+
onPress={incrementKey}
307+
style={styles.button}
308+
/>
309+
<Button title="GC" onPress={collectGarbage} style={styles.button} />
310+
</View>
298311
<Button
299312
title="Set input's value"
300313
onPress={openValueModal}

0 commit comments

Comments
 (0)