Dialogs React component confirm dialog Mar 28, 2018 1 min read react-confirm-alert react component confirm dialog. Getting started Install with NPM: $ npm install react-confirm-alert --save Options const options = { title: 'Title', message: 'Message', buttons: [ { label: 'Yes', onClick: () => alert('Click Yes') }, { label: 'No', onClick: () => alert('Click No') } ], childrenElement: () => <div />, customUI: ({ title, message, onClose }) => <div>Custom UI</div>, willUnmount: () => {} } confirmAlert(options) React JSX Use with function: import { confirmAlert } from 'react-confirm-alert'; // Import import 'react-confirm-alert/src/react-confirm-alert.css' // Import css class App extends React.Component { submit = () => { confirmAlert({ title: 'Confirm to submit', message: 'Are you sure to do this.', buttons: [ { label: 'Yes', onClick: () => alert('Click Yes') }, { label: 'No', onClick: () => alert('Click No') } ] }) }; render() { return ( <div className="container"> <button onClick={this.submit}>Confirm dialog</button> </div> ); } } React JSX Custom UI Component confirmAlert({ customUI: ({ onClose }) => { return ( <div className='custom-ui'> <h1>Are you sure?</h1> <p>You want to delete this file?</p> <button onClick={onClose}>No</button> <button onClick={() => { this.handleClickDelete() onClose() }}>Yes, Delete it!</button> </div> ) } }) Js GitHub GA-MO/react-confirm-alert?? — Read MoreDownload as zip DialogsModalsPopup
Modals Video Tutorial: make a modal in ReactJS Video Tutorial: make a modal in ReactJS 11 February 2022
Modals A simple modal to display some customizable text, built with react A simple modal to display some customizable text, built with react 18 January 2022