模态属性"显示"在类型"内在属性"上不存在



我使用的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道具。这解决了我的问题!

最新更新