我使用的Modal
组件与react-bootstrap
文档中所示完全相同,但我得到了错误Property 'show' does not exist on type 'IntrinsicAttributes & [...]'
<Modal show={props.showModal} onHide={props.handleCloseModal}>
<Modal.Header closeButton>
<Modal.Title>Seleccionaste la opcion:</Modal.Title>
</Modal.Header>
<Modal.Body>
[...]
在node_modules/react-bootstrap/esm/Modal.d.ts
中挖掘后,我发现react-bootstrap@^1.3.0
的类型定义中实际上不存在show
(奇怪的是,根据官方网站,这是最新版本,甚至文档告诉你使用该道具(。
所以我的解决方案是安装@types/react-bootstrap
,其中肯定包含show
道具。这解决了我的问题!