反应-未加载引导手风琴 [英] react-bootstrap Accordion not loading

查看:12
本文介绍了反应-未加载引导手风琴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对Bootstrap 5使用Reaction-Bootstrap。我想在我的一个页面中使用Accordion。为此,我只复制了这个页面的结构->;https://react-bootstrap.netlify.app/components/accordion/。但当我打开页面时,浏览器显示此错误-

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `Questions`.

以下是我使用此组件的代码

import Accordion from 'react-bootstrap/Accordion';

const Questions = () => (
    <Accordion defaultActiveKey="0" flush>
        <Accordion.Item eventKey="0">
            <Accordion.Header>Question #1</Accordion.Header>
            <Accordion.Body>
                Answer to the Question #1
            </Accordion.Body>
        </Accordion.Item>
        <Accordion.Item eventKey="1">
            <Accordion.Header>Question #2</Accordion.Header>
            <Accordion.Body>
                Answer to the Question #2
            </Accordion.Body>
        </Accordion.Item>
    </Accordion>
);


export default Questions;

其他详细信息:

  1. 引导:";^5.0.2";
  2. 反应&:^17.0.2&q;
  3. ";react-bootstrap";:";^1.6.1";

我在导入/导出组件时是否遗漏了什么?TIA。

推荐答案

我通过将Reaction-Bootstrap v1.6.1替换为最新的v2.0.0beta;https://www.npmjs.com/package/react-bootstrap/v/2.0.0-beta.0修复了此问题

npm uninstall react-bootstrap
npm i react-bootstrap@2.0.0-beta.0

我希望这能解决您的问题

这篇关于反应-未加载引导手风琴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆