-
-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Android): incorrect childCount in removeViewAt when using flatlis…
…t on fabric (#2307) ## Description This PR intents to fix the crash when navigating back from a screen with FlatList on the new architecture. The crash was caused by miscalculated `childCount` of the list. Earlier on I found out that setting the [removeClippedSubviews](https://reactnative.dev/docs/flatlist#removeclippedsubviews) option to false (defaults to true on Android) in the FlatList fixes the problem. This PR is rather a quick fix with an extra condition, that adds simple views in place of the miscalculated ones in `startTransitionRecursive` function if there's a FlatList with `removeClippedSubviews` option set. Fixes #2282. ## Changes - added `Test2282.tsx` repro - added extra condition in `startTransitionRecursive` function <!-- ## Screenshots / GIFs Here you can add screenshots / GIFs documenting your change. You can add before / after section if you're changing some behavior. ### Before ### After --> ## Test code and steps to reproduce - added `Test2282.tsx` repro ## Checklist - [x] Ensured that CI passes
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { FlatList, Button, Text } from 'react-native'; | ||
import { createNativeStackNavigator } from '@react-navigation/native-stack'; | ||
import { NavigationContainer } from '@react-navigation/native'; | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
const First = ({ navigation }: any) => ( | ||
<Button onPress={() => navigation.navigate('Second')} title="Navigate" /> | ||
); | ||
|
||
const Second = ({ navigation }: any) => ( | ||
<> | ||
<FlatList | ||
renderItem={({ item }) => <Text>{item}</Text>} | ||
data={[1,2,3,4,5,6]} | ||
keyExtractor={item => item.toString()} | ||
/> | ||
<Button onPress={navigation.goBack} title="Go back" /> | ||
</> | ||
); | ||
|
||
export default function App() { | ||
return ( | ||
<NavigationContainer> | ||
<Stack.Navigator> | ||
<Stack.Screen name="First" component={First} /> | ||
<Stack.Screen name="Second" component={Second} /> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters