Skip to content

Instantly share code, notes, and snippets.

@primaryobjects
Created November 1, 2017 19:03
Show Gist options
  • Save primaryobjects/aacf6fa49823afb2f6ff065790a5b402 to your computer and use it in GitHub Desktop.
Save primaryobjects/aacf6fa49823afb2f6ff065790a5b402 to your computer and use it in GitHub Desktop.
A simple example of a confirm alert dialog in ReactJs / React.
<div className='delete-button' onClick={() => { if (window.confirm('Are you sure you wish to delete this item?')) this.onCancel(item) } } />
@hascos
Copy link

hascos commented May 16, 2021

@MuhammedAnasm4444 share your code

@xrsrke
Copy link

xrsrke commented May 21, 2021

💖🙏

@kinucris
Copy link

Ty for idea!

I'm use like this:

<DeleteIcon onClick={() => { window.confirm( 'Confirmar exclusão?', ) && deleteIncidente( row.id, ); }} />

@ronaldmgdev
Copy link

onClick={ ()=> { window.confirm("Your message") && function/expression }}

@jukkamic
Copy link

Thank you!

@badrannn
Copy link

badrannn commented Nov 7, 2021

Thank YOU!

@sarakahaveci
Copy link

thank you, this way, worked perfectly with my code!
onClick={() => { window.confirm( 'Are you sure you want to delete this Card?', ) && deleteCard(id) }}

@MahfudW
Copy link

MahfudW commented Aug 1, 2022

from Indonesia, thank you so much. No style css but it works.

@raju-hanumappa
Copy link

Thank you so much. Nice one.

@AlfonsoDubon
Copy link

thank you, this way, worked perfectly with my code! onClick={() => { window.confirm( 'Are you sure you want to delete this Card?', ) && deleteCard(id) }}

GENIAL!!! great work

@longpt2022
Copy link

thank u

@imueLx
Copy link

imueLx commented Nov 3, 2022

Thank you, it works! and it's very simple

@sanryuu03
Copy link

thank you, this way, worked perfectly with my code! onClick={() => { window.confirm( 'Are you sure you want to delete this Card?', ) && deleteCard(id) }}

thanks. tested Next js "v13.1.6"

@Ginasonia98
Copy link

thankyou it's work for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment