const [workout,setWorkout] = useState({
workoutname:"",
exercisesSelection:[],
});
const SaveWorkout = async ()=>{
setWorkout(prevArr=>{
return {
...prevArr,
workoutname:workoutName,
exercisesSelection:currentExercises
}
})
console.log(workout)
await addDoc(workoutsCollectionRef,{
workoutName:workout.workoutname,
exercises:workout.exercisesSelection,
})
}
Documment is being added with the values empty. I believe that the state is changing after the addDoc.