Skip to content

Thamodaran/react-confirmation

Repository files navigation

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

About

React confirmation dialog box

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published