Home > front end >  How to import "useAccordionButton"?
How to import "useAccordionButton"?

Time:09-22

Using "react-bootstrap"

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

Gives error message:

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

CodePudding user response:

Your NPM list states you are using [email protected] yet your code is referencing the 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, or change your version to 2.0.0-rc.0 if you need that API.

CodePudding user response:

Accordion.Button is available in react-bootstrap v5 (v2.0.0-rc0)

Accordion.Button

You have v4 [email protected] installed.

Uninstall the current version and install latest.

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