Skip to content

KeyboardAvoidingView with FlatList performance issue #871

@andreibahachenka

Description

@andreibahachenka

Describe the bug
Hey guys, I have a very basic setup from the examples in the repository, I've attached the video with the performance
Performance is not smooth while using KeyboardAvoidingView with FlatList

Would appreciate If anybody can help with fixing it

Code snippet

const reversedMessages = new Array(100).fill(0)

const RenderItem = ({ item, index }: any) => {
		return (
			<View key={index}>
				<Text>{index}</Text>
			</View>
		)
	}

	return (
		<View style={styles.screenContainer}>
			<KeyboardAvoidingView
				behavior="padding"
				keyboardVerticalOffset={headerHeight}
				style={styles.container}
			>
				<FlatList
					inverted
					contentContainerStyle={styles.contentContainer}
					data={reversedMessages}
					initialNumToRender={15}
					renderItem={RenderItem}
				/>
				<Input />
			</KeyboardAvoidingView>
		</View>
	)
}

const styles = StyleSheet.create() => ({
	screenContainer: {
		backgroundColor: 'white,
		flex: 1,
	},
	container: {
		flex: 1,
	},
	contentContainer: {
		justifyContent: 'flex-start',
		flexGrow: 1,
	},
}))

To Reproduce
Steps to reproduce the behavior:

just copy the code and look at the performance

Expected behavior
Smooth animation for FlatList

Screenshots

Screen.Recording.2025-03-20.at.2.24.03.PM.mov

Smartphone (please complete the following information):
I use Expo SDK 52

  • Desktop OS: MacOS 15.3.1
  • Device: Simulator iPhone 16 Pro
  • OS: 18.0
  • RN version: 0.76.6
  • RN architecture: fabric
  • JS engine: Hermes
  • Library version: ^1.16.7

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions