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)