I'm creating a react app and i'm using firebase/firestore for the database. I want to have a textarea that updates the name of an object inside of an array in the firestore db.
The structure of the db looks like this:
I want to update the name property of one of the objects in the "categories" array.
The code I've written so far looks like this:
const updateCategoryInfo = async (categoryId: number, categoryName: string) => {
await updateDoc(docRef, {
[`categories[${categoryId}].name`]: categoryName
})
.then(() => {
console.log("Category updated succesfully!")
})
.catch((error) => {
console.error("Error updating categoryname", error)
})
}
The code gives this error: