When I use the setNumberOfExpensesOfTheCar() it is not saving the value, however when I do a console.log() of it it prints correctly.
It doesn't matter if I use line 4 or 5, the value is not saved
Nn line 6 you don't see the print but on lines 7 and 8 yes.
What am I doing wrong?
Thank you very much and sorry if the format is not correct. (It's my first post)
1. const [numberOfExpensesOfTheCar, setNumberOfExpensesOfTheCar] = useState("");
2. const actualCarRef = doc(db, "vehicles", actualCar);
3. const actualCarSnap = await getDoc(actualCarRef);
4. setNumberOfExpensesOfTheCar((actualCarSnap.get("numberOfExpenses")).toString());
5. setNumberOfExpensesOfTheCar((actualCarSnap.get("numberOfExpenses")));
6. console.log(numberOfExpensesOfTheCar);
7. console.log(actualCarSnap.get("numberOfExpenses").toString());
8. console.log(actualCarSnap.get("numberOfExpenses"));
``