Simplest confirmation model dialog


(Adcoolguy) #1

We do not need an advanced dialog (like another React component just for this), thus we wrote:

onClick=“if(confirm(‘Delete the item?’)) {this.deleteItem};”

But we got:

Uncaught Invariant Violation: Expected onClick listener to be a function, instead got type string

How do we workaround this error?

TIA


(Tran Trung Tin) #2

Of course you need an function attach to onClick, something like this: onClick={() => {if(confirm('Delete the item?')) {this.deleteItem};}}


(Adcoolguy) #3

You are the man! Thanks so much! :slight_smile:


(Khushboo Mulani) #4

Can we in any way change the title of the confirmation box that appears?