이제 거의 끝났습니다! 삭제 아이콘을 TouchableOpacity 컴포넌트로 감싸고 onPress Props를 설정해주세요.
components/TodoItem.js
import React from 'react'; import {View, Text, StyleSheet, Image, TouchableOpacity} from 'react-native'; import Icon from 'react-native-vector-icons/MaterialIcons'; function ({id, text, done, onToggle, onRemove}) { return ( <View style={styles.item}> <TouchableOpacity onPress={() => (id)}> <View style={[styles.circle, done && styles.filled]}> {done && ( <Image source={ ('../assets/icons/check_white/check_white.png')} /> )} </View> </TouchableOpacity> <Text style={[styles.text, done && styles.lineThrough]}>{text}</Text> {done ? ( <TouchableOpacity onPress={() => onRemove(id)}> <Icon name="delete" size={32} color="red" /> </TouchableOpacity> ) : ( <View style={styles.removePlaceholder} /> )} </View> ); } (...)
항목이 잘 삭제되는지 확인해보세요!