Shows a confirmation dialog (modal) and the user needs to accept or cancel.
npm i --save react-confirmation-dialog
import React, { useState } from 'react';
import Confirmation from 'react-confirmation-dialog';
function App() {
const [display, setDisplay] = useState(true);
const acceptFunction = () => {
console.log('Accept');
setDisplay(false);
}
const cancelFunction = () => {
console.log('Cancel');
setDisplay(false);
}
return (
<div>
{ display
? <Confirmation
mainMessage = {'Do you want to download your data?'}
acceptFunction = {acceptFunction}
acceptButton = {'Accept'}
cancelFunction = {cancelFunction}
cancelButton = {'Cancel'}
/>
: null
}
</div>
);
}
export default App;
This component is open source and available under the MIT License.