why the input value shows a type of string instead of type of number?

Viewed 30

I am trying to get the input value type of number. But the value keep showing me its a type of string. How do i fix this?

const [price, setPrice] = useState();

const handlePrice = (event) => {
    console.log(event.target.value);
    setPrice(event.target.value);
};

        <div className="col-md-6">
          <label for="inputPrice" className="form-label">
            Price
          </label>
          <input
            value={price}
            onChange={handlePrice}
            type="number"
            className="form-control"
            id="inputPrice"
          />
        </div>
        <div className="col-12">
1 Answers
const handlePrice = (event) => {
    console.log(event.target.value);
    // setPrice(parseInt(event.target.value));
    // setPrice(event.target.value * 1);
    setPrice(Number(event.target.value));
};
Related