Hi I using Vue 3 with Typescript. In my code I have variable:
const editItem = ref<{
id: number
title: string
author: string
}>({
id: 0,
title: '',
author: '',
})
This variable I update using this method:
const updateItem = (data: {
id: number
title: string
author: string
}) => {
const { title, author } = data
getBooks.value = getBooks.value.map(book => ({
...book,
title: editItem.value.id === book.id ? title : book.title,
author: editItem.value.id === book.id ? author : book.author,
}))
}
Did this code is correctly by typescript? I readed that I should using reactive instead of ref to object, but reactive value can not be empty
getBooks
? Does the code work as you expect it to do? \$\endgroup\$ – Simon Forsberg Nov 1 '20 at 12:21