Oops, my friends, I have this "problem" when using setState, as setState is not asynchronous I can't use it the way I want. I set the value and when calling the function to send back the value returns with "delay". How do I resolve this?
const [quantityProduct, setQuantityProduct] = useState<number>(0);
function addQuantity() {
var soma = Number(quantityProduct) + 1;
setQuantityProduct(soma);
sendProduct()
}
function sendProduct() {
console.log(quantityProduct)
}