Adil Asif
Adil Asif

Reputation: 23

Ant design message doesnot work on onclick

So I am trying to display a message when a button is clicked but what it does is that when the page is loaded it displays message boxes (which should not happen) but it doesn't work on onclick I have attached the screenshots to my code and views. enter image description here

enter image description here

enter image description here

Upvotes: 0

Views: 3452

Answers (1)

wmattei
wmattei

Reputation: 494

You need to pass your function to the onClick parameter, not invoke it.

<Button type="primary" shape="round" onClick={() => info()} />

or

<Button type="primary" shape="round" onClick={info} />

Upvotes: 4

Related Questions