From 151e17675c8a46e57af4e6664ff2669416739e33 Mon Sep 17 00:00:00 2001 From: Rei Date: Thu, 28 Dec 2023 14:24:56 +0000 Subject: [PATCH] Declare incidents as an empty array --- src/App.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/App.js b/src/App.js index 3620f6e..e02a3a2 100644 --- a/src/App.js +++ b/src/App.js @@ -34,6 +34,7 @@ export function MyForm(props) { const [date, setDate] = useState(''); const [context, setContext] = useState(''); const [selectedOptions, setSelectedOptions] = useState([]); + const [incidents, setIncidents] = useState([]); // Declare incidents as an empty array // Create a function to handle the checkbox changes and update the state accordingly. const handleCheckboxChange = (event) => { @@ -50,9 +51,9 @@ export function MyForm(props) { const submitHandler = async (event) => { event.preventDefault() - const incidents = { setSubmitter, setDate, setContext, setSelectedOptions } + const incidentsData = { submitter, date, context, selectedOptions } // Use the state variables directly const col = collection(db, `incidents/${props.incidentId}/incident_logs`) - const ref = await addDoc(col, incidents) + const ref = await addDoc(col, incidentsData) console.log(ref) }