我在我的项目中使用react-bootstrap。在使用Modal组件时出现如下错误。
模态组件:
<Modal show={this.state.modalshow} onHide={close} container={this} aria-labelledby="contained-modal-title">
<Modal.Header closeButton>
<Modal.Title id="contained-modal-title">Add User</Modal.Title>
</Modal.Header>
尝试在顶部添加
import Modal from 'react-bootstrap/lib/Modal';
// or
import { Modal } from 'react-bootstrap';
在First Install React bootstrap中使用以下命令 -
npm install --save react-bootstrap
之后从react-bootstrap导入Modal
import {Button,Modal} from 'react-bootstrap'
<Button bsStyle="primary" type="submit">Create</Button>
如果这个代码适合你,即react-bootstrap工作正常,尝试使用你的模态代码将工作正常。 否则你的react-bootstrap安装有问题。