这是我的React Bootstrap模式组件。我正在动态加载componentDidMount()
中的下拉列表,但是当我关闭模态时,模态组件不会卸载。
如何在Modal组件关闭时卸载它,以便它可以再次安装并在每次重新打开时重新加载动态数据?
return ( <div className="backdrop" style={backdropStyle}> <Modal.Dialog> <Modal.Header> <Modal.Title>Configure Node</Modal.Title> </Modal.Header> <Modal.Body> <div className="container"> <div className="row"> <label className="col-md-4" >Data Source: </label> <select className="col-md-7"> {renderedSources} </select> </div> <div className="row col-md-3"> </div> </div> </Modal.Body> <Modal.Footer> <Button variant="secondary" onClick={this.props.onClose}>Close</Button> <Button variant="primary" onClick={this.props.saveModal}>Save changes</Button> </Modal.Footer> </Modal.Dialog> </div> ); ConfigurationModal.propTypes = { onClose: PropTypes.func.isRequired, visibility: PropTypes.bool, saveModal: PropTypes.func.isRequired };