bug when trigger the function in props
Vue version
3.3.4
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-qh2ne5?file=src%2FApp.tsx,package.json
Steps to reproduce
add 1 item then add 1 item then add 1 item then add 1 item
click the first delete-button and then click the first delete-button twice , and go on clicking it ,
you can see that the last item can't be deleted
What is expected?
last item can be deleted
What is actually happening?
the last one can't be deleted because the index in the onDelete function callback is not correct
System Info
No response
Any additional comments?
No response
The index is cached by the closure, which causes the index to still be the original value after deleting the element, resulting in a deletion error.
setup(props) {
return () => {
// when deconstructing props, move that into the render function. setup itself only runs once.
const { item, onDelete } = props;
return (<div>
<input
type="checkbox"