如何解决简单的React-multi-carousel示例失败
我正在尝试使用react-multi-carousel
的基本用法:
import React from 'react';
import {Carousel} from 'react-multi-carousel';
export function MyComponent(props) {
// ...
return (
<Carousel>
<div>Item 1</div>
<div>Item 2</div>
</Carousel>
);
};
但是我得到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 'MyComponent'.
我已将react-multi-carousel
与npm i react-multi-carousel
一起安装。我究竟做错了什么?任何帮助将不胜感激。
解决方法
您需要使用默认导入,因为错误提示import Carousel from "react-multi-carousel"
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。