react-confirmation

0.0.7 • Public • Published

React confirmation dialog box

Install

npm install react-confirmation --save

Demo

demo

Usage

React confirmation dialog example
import React, { Component } from 'react';
import Confirmation from 'react-confirmation';
 
class Confirmation extends Component {
  constructor(props) {
    super(props);
    this.state = {
      showConfirm: false
    };
  }
  handelConfirmation = () => {
    this.setState({ showConfirm: !this.state.showConfirm });
  }
  render() {
    const confirmOptions = {
      title: 'Confirm to submit',
      message: 'Are you sure want to do this..?',
      buttons: [
        {
          label: 'Cancel',
          onClick: () => {
            this.setState({ showConfirm: false });
          }
        },
        {
          label: 'Ok',
          onClick: () => { alert("ok") }
        }
      ]
    };
    return (
      <React.Fragment>
        {this.state.showConfirm ? <Confirmation options={confirmOptions} /> : ''}
      </React.Fragment>
    );
  }
}

PROPTYPES

Prop Type Required
options Object Yes

react-confirmation

Package Sidebar

Install

npm i react-confirmation

Weekly Downloads

1

Version

0.0.7

License

MIT

Unpacked Size

277 kB

Total Files

9

Last publish

Collaborators

  • thamodaran