When i create touchable-opacity or buttons using v-for loop, the on-press functions of all buttons are called even though i haven't touch any of them. But there isn't any problem with normal button using the same function as handler.
<view v-for="taskDay in buttons" :key="taskDay.id" class="task-day">
<touchable-opacity
v-for="task in taskDay.next"
:key="task.id"
:on-press="handleTouch(task.id)"
class="task">
</touchable-opacity>
</view>
methods: {
handleTouch: function(id) {
console.log(id);
}
},
There isn't much on the internet about vue native. Can anyone help?
I am facing exactly the same issue....
UPDATE: I dived more deep in the topic, and it turned out is a known issue in native base. Checkbox is touchable opacity in react native, and button as well with a composition of views in some order, thats why you have problems in both cases.
See the native base issue in github: https://github.com/GeekyAnts/NativeBase/issues/3038
However, I could find a workaround. This is not exactly a checkbox, I use tick icon to display that the item is checked, and I iterate through a touchable opacity from native base. But with some styling you can create a checkbox I am sure.
In the checkItem method I use splice and replace the item to preserve reactivity:
My dataArray is an array like that:
I hope it will help to resolve your problem.