0

How to create a search query on a click of button that includes product id and quantity like this one: http://localhost:3000/cart/6321559991c236d100b290d1?qty=2 I have tried this:

const addToCartHandler = () => {
    navigate({ pathname: `/cart/${id}`, search: `?qty=${qty}` });
  };

But I don't think it is a wise solution to use it like this.

I am actually learning react js and the instructor used a useHistory hook but now it is not working as it is deprecated (I think)

John Oliver
  • 125
  • 1
  • 11

1 Answers1

0

You can do this way, or you can do http://localhost:3000/cart?id=6321559991c236d100b290d1&qty=2

PeterT
  • 487
  • 3
  • 9