This is because your currentInvoice
is an array, since you store it this way:
setCurrentInvoice(
snapshot.docs.map((doc) => ({ id: doc.id, data: doc.data() }))
)
You can access the name like this:
console.log(currentInvoice[0].data.name);
However, if you only want to store the first invoice, you can do it so:
setCurrentInvoice(snapshot.docs[0].data());
And then access the name like you wanted first:
console.log(invoice.name);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…