如何导入"useAccordionButton"?

How to import "useAccordionButton"?

使用“反应-bootstrap”

import { useAccordionButton } from 'react-bootstrap/AccordionButton';

给出错误信息:

Module not found: Can't resolve 'react-bootstrap/AccordionButton'

npm list

bsn-gui@0.1.0 C:\goproj\src\github.com\amortaza\bsn-gui
├── @testing-library/jest-dom@5.14.1
├── @testing-library/react@11.2.7
├── @testing-library/user-event@12.8.3
├── bindings@1.5.0 extraneous
├── bootstrap@5.1.1
├── file-uri-to-path@1.0.0 extraneous
├── nan@2.15.0 extraneous
├── react-bootstrap-validation@0.1.11
├── react-bootstrap@1.6.3
├── react-dom@17.0.2
├── react-scripts@4.0.3
├── react-split@2.0.13
├── react@17.0.2
└── web-vitals@1.1.2

Accordion.Button 在 react-bootstrap v5 (v2.0.0-rc0)

中可用

Accordion.Button

您安装了 v4 react-bootstrap@1.6.3

卸载当前版本并安装最新版本。

npm uninstall -S react-bootstrap
npm install -S react-bootstrap@2.0.0-rc.0

您的 NPM 列表表明您正在使用 react-bootstrap@1.6.3,但您的代码引用了 2.0.0-rc.0 API. Of course, as with all third-party tools, you must reference the documentation relevant to the version you choose to use. Refer to the proper documentation for 1.6.3,或者如果需要,请将您的版本更改为 2.0.0-rc.0 API.