我正在使用SweetAlert2来提醒用户。当我点击确认按钮时,行为符合预期,删除关键字调用。
render: function() {
return(
<SweetAlert show={this.state.show} title="Context Processor"
text="Keyword deletion cannot be undone. Do you still want to continue?"
onConfirm={this.deleteKeyword}
showCloseButton={true}
heightAuto={false}>
</SweetAlert>
)},
deleteKeyword: function() {
this.setState({show: false});
this.props.deleteKeyword(this.state.keyword);
},
但是,当我只是关闭警报框时,再次拨打电话!我浏览了图书馆提供的各种选项 - https://github.com/kessejones/react-sweetalert2/blob/master/src/ReactSweetAlert2.js,但我找不到任何兴趣。此外,添加了showCloseButton
参数,但当我点击它时,再次进行删除关键字调用。
有什么建议?
我把方法改为onConfirm={(e) => {this.deleteKeyword(e)}}
e告诉我它是否被证实或被驳回。