我正在尝试从父组件按钮打开/关闭 reactstrap 模式,但我无法让它工作。
我将状态isModalOpen作为道具传递给子ModalExample组件,它会按照我制作的调试文本字段中的显示进行更改,但模态似乎没有打开。
任何帮助表示赞赏。这是一个 jsfiddle:https ://jsfiddle.net/67wy5nqp/
const { Button, Modal, ModalHeader, ModalBody, ModalFooter } = Reactstrap;
class ModalExample extends React.Component {
constructor(props) {
super(props);
console.log(this.props);
}
render() {
return (
<div>
<br />
<label>
(child) this.props.isOpen
<input type="text" value={this.props.isOpen} />
</label>
<Modal
isOpen={this.props.isModalOpen}
toggle={this.props.toggleModalView}
className={this.props.className}
>
<ModalHeader toggle={this.props.toggleModalView}>
Modal title
</ModalHeader>
<ModalBody>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad …Run Code Online (Sandbox Code Playgroud)