【发布时间】:2019-03-31 11:15:48
【问题描述】:
我正在学习反应,我想在“发布”回调后关闭引导模式
所以,在下面的代码中,当onClick={() => postDocument.callApi(this.state.document, this.hideModal)} 回调时,我想在“hideModal”方法中隐藏模式。
我该怎么做?
import React, { Component } from "react";
import postDocument from "./../rest/PostDocument";
import fetchPersons from "./../rest/FetchPersons";
import PersonList from "./../components/PersonList";
import ShowDatePicker from "./../components/ShowDatePicker";
import moment from "moment";
class SaveDocument extends Component {
state = {
persons: [],
document: {
documentDate: moment(),
personFrom: {
id: ""
},
personTo: {
id: ""
},
comments: ""
}
};
hideModal = hideModalInfo => {
// How do I hide the modal here!
};
render() {
return (
<div
className="modal fade"
id="basicExampleModal"
tabIndex="-1"
role="dialog"
aria-labelledby="exampleModalLabel"
aria-hidden="true"
>
<div className="modal-dialog" role="document">
<div className="modal-content">
<div className="modal-header">
<h5 className="modal-title" id="exampleModalLabel">
Save document
</h5>
<button
type="button"
className="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div className="modal-footer">
<button
type="button"
className="btn btn-primary"
onClick={() => postDocument.callApi(this.state.document, this.hideModal)}
>
Save changes
</button>
</div>
</div>
</div>
</div>
);
}
}
export default SaveDocument;
【问题讨论】:
标签: reactjs bootstrap-4 bootstrap-modal