Next.js Discord

Discord Forum

DaisyUI button is not firing onClick function

Unanswered
Northeast Congo Lion posted this in #help-forum
Open in Discord
Northeast Congo LionOP
I was trying to make a button which add a product in my cart. But the button is sometimes firing the onClick or sometimes it doesn't I can't understand the exact reason
Also I'm using use client.

Here's my code:
   <button
                  className="btn btn-primary"
                  onClick={() => dispatch(cartSlice.actions.addToCart(product))}
                >
                  Add to cart
                </button>

1 Reply

how do you know it doesnt? if you console log inside the onclick you are saying it wont print every click?