1import { confirmAlert } from 'react-confirm-alert'; // Import
2import 'react-confirm-alert/src/react-confirm-alert.css'; // Import css
3
4class App extends React.Component {
5 submit = () => {
6 confirmAlert({
7 title: 'Confirm to submit',
8 message: 'Are you sure to do this.',
9 buttons: [
10 {
11 label: 'Yes',
12 onClick: () => alert('Click Yes')
13 },
14 {
15 label: 'No',
16 onClick: () => alert('Click No')
17 }
18 ]
19 });
20 };
21
22 render() {
23 return (
24 <div className='container'>
25 <button onClick={this.submit}>Confirm dialog</button>
26 </div>
27 );
28 }
29}