score:0

you're calling the function directly. so it triggers a re-render. assign a function the onclick handler rather than calling it.

onclick={() => setproduct(e.product_id), () => { addproduct(e.product_id) }

score:0

you can't call directly setproduct directly.

onclick={() => setproduct(e.product_id), () => { addproduct(e.product_id) }

another way, simple and easy to read.

const clickhandler = (e) => {
  setproduct(e.product_id);
  addproduct(e.product_id);
}

<a href="#" class="btn btn-success" onclick={clickhandler} >something</a>

Related Query

More Query from same tag