i am trying to build a calculation platform and i got an issue in that process when i am trying to clearing the state of my input value its last value store in it and because of that i am not able to perform certain task here the code
import React, { useState } from "react";
const App = () => {
const [buyPrice, setBuyPrice] = useState(8000);
const [buyAMount, setBuyAMount] = useState(0);
const [buy_total, setBuy_total] = useState(0);
const handleBuyChange = (e) => {
  var { name, value } = e.target;
  if (name == 'buyPrice') {
    setBuyPrice(value);
  }
  if (name == 'buyAMount') {
    setBuyAMount(value);
  }
  if (name == 'buy_total') {
    setBuy_total(value);
  }
  console.log('alert',buyPrice,buyAMount,buy_total)
};
return (
  <div>
    <div>
      <input
        type={"number"}
        name="buyPrice"
        value={buyPrice}
        onChange={(e) => handleBuyChange(e)}
      />
      <input
        type={"number"}
        name="buyAMount"
        value={buyAMount}
        onChange={handleBuyChange}
      />
      <input
        type={"number"}
        name="buy_total"
        value={buy_total}
        onChange={handleBuyChange}
      />
    </div>
  
  </div>
);
};
Heres the console:-- img
 
     
    