Let's think about it this way for a moment
The empty state — showing 'No todos yet!' when the todo list is empty — is an important piece of UX polish, and you can implement it with FlatList's ListEmptyComponent prop. Pressing a todo item navigates to a Detail screen (using React Navigation from earlier chapters), where you can show the todo's full details or an edit screen.
Let's connect it to a real scenario
Add FlatList's ListEmptyComponent={<Text>No todos yet! Add one above.</Text>} and it'll only show up when the todos array is empty. Wire up each todo item's onPress with navigation.navigate('TodoDetail', { todoId: item.id }), then in the TodoDetail screen look up the todo using route.params.todoId (React Navigation's route params pattern).
Code Example
<FlatList
data={todos}
keyExtractor={(item) => item.id}
ListEmptyComponent={
<Text style={styles.emptyText}>No todos yet! Add one above 👆</Text>
}
renderItem={({ item }) => (
<TouchableOpacity
style={styles.todoItem}
onPress={() => navigation.navigate('TodoDetail', { todoId: item.id })}
>
<Text>{item.done ? '☑️' : '☐'} {item.text}</Text>
<TouchableOpacity onPress={() => deleteTodo(item.id)}>
<Text>🗑️</Text>
</TouchableOpacity>
</TouchableOpacity>
)}
/>When the todo list is empty, an empty state message shows up, and pressing a todo item navigates to the Detail screen.5-Minute Try-It
Keep building out the Todo App with ListEmptyComponent + navigation (the Detail screen) until it's complete — this is the capstone project for the whole tutorial.
A Quick Word of Caution
With nested TouchableOpacity (item press + delete button press), React Native's event bubbling behavior can differ slightly by platform (iOS/Android) — be sure to test on both.