React-confirm-bootstrap - 是否有'onCancel'方法?

时间:2017-11-06 13:40:52

标签: reactjs confirm

我使用react-confirm-bootstrap模式显示确认框,但我无法处理“取消”选项。如果用户选择取消,我想做点什么。是否存在与 onConfirm 类似的 onCancel 方法?或者我该如何处理?

var Confirm = require('react-confirm-bootstrap');

var ConfirmAction = React.createClass({
    onConfirm() {
        // Preform your action.
    },

    render() {
        return (
            <Confirm
                onConfirm={this.onConfirm}
                body="Are you sure you want to delete this?"
                confirmText="Confirm Delete"
                title="Deleting Stuff">
                <button>Delete Stuff</button>
            </Confirm>
        )
    },
});

1 个答案:

答案 0 :(得分:0)

onClose:React.PropTypes.func

关闭后调用的函数。

var ConfirmAction = React.createClass({
    onConfirm() {
       // Preform your action.
    },
    afterClose() {
      // you code after close
    },


    render() {
        return (
            <Confirm
                onConfirm={this.onConfirm}
                body="Are you sure you want to delete this?"
                confirmText="Confirm Delete"
                title="Deleting Stuff">
                onClose={this.afterClose}
                <button>Delete Stuff</button>
            </Confirm>
        )
    },
});