Zend certified PHP/Magento developer

pleas what is the best way to update an amount , thanks [closed]

const [amount, setAmount] = useState(1);
const stock =8;

const increment = () => {
    setAmount((oldAmount) => {
      let tempAmount = oldAmount + 1;
      if (tempAmount > stock) {
        tempAmount = stock;
      }
      return tempAmount;
    });
  };

// or  if (stock > amount) setAmount(amount + 1);

const decrement = () => {
    setAmount((oldAmount) => {
      let tempAmount = oldAmount - 1;
      if (tempAmount < 1) {
        tempAmount = 1;
      }
      return tempAmount;
    });
  };
// or if (amount > 1) setAmount(amount - 1);