when I click on icon with touchableopacity in react native first time its not working but 2nd time it works

39 Views Asked by At

when I click on icon with touchableopacity in react native first time its not working but 2nd time it works

<View>
        <TextInput
          style={styles.input}
          placeholder="Add new task"
          value={task}
          onChangeText={setTask}
        />
        <MyPressable
          style={styles.button}
          android_ripple={{ color: 'powderblue' }}
          touchOpacity={0.6}
          onPress={handleAddTask}
        >
          <Text style={styles.buttonText}>Add Task</Text>
        </MyPressable>
 </View>


<TouchableOpacity onPressIn={() => deleteTask(index)}>
   <Icon name="trash" size={20} color="black" />
</TouchableOpacity>


I just want it work as I click on Icon

1

There are 1 best solutions below

0
On

change onPressIn to onPress in props TouchableOpacity