Skip to content

erikmartinjordan/react-confirmation-dialog

Repository files navigation

react-confirmation-dialog

react-confirmation-dialog version react-confirmation-dialog license

Shows a confirmation dialog (modal) and the user needs to accept or cancel.

Installation

npm i --save react-confirmation-dialog

Example

react-emoji-dialog

How to use

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;

Author

Erik Martín Jordán

License

This component is open source and available under the MIT License.

About

✔️ Simple modal form with 2 options: accept and cancel.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published