I'm trying to add a new field(reactions) to an existing document using updateDoc
method but it's not adding a new field.
This is how I'm doing:
const newUserReactions = [...reactions, newReaction]
console.log(newUserReactions)
updateDocument(docID, { reactions: newUserReactions })
reactions
field doesn't exist on the document
updateDocument:
const updateDocument = async (id, updates) => {
dispatch({ type: "IS_PENDING" })
try {
const updatedDocument = await updateDoc(doc(db, c, id), updates)
dispatchIfNotCancelled({ type: "UPDATED_DOCUMENT", payload: updatedDocument })
return updatedDocument
} catch (error) {
dispatchIfNotCancelled({ type: "ERROR", payload: error })
return null
}
}