I'm trying to import react-owl-carousel in my project. I see the error mentioning, "Cannot read properties of undefined (reading 'fn')". Although I've properly installed owlCarousel. Here is my "App.js":
import React from "react";
import OwlCarouselDemo from "./OwlCarouselDemo";
const App = () => {
return (
<div>
<h1>React Owl Carousel Demo</h1>
<OwlCarouselDemo />
</div>
);
};
export default App;
And this is "OwlCarouseldemo.js":
import React from "react";
import OwlCarousel from "react-owl-carousel";
import "owl.carousel/dist/assets/owl.carousel.css";
import "owl.carousel/dist/assets/owl.theme.default.css";
const items = [
{ id: 1, text: "Slide 1" },
{ id: 2, text: "Slide 2" },
{ id: 3, text: "Slide 3" },
{ id: 4, text: "Slide 4" },
{ id: 5, text: "Slide 5" }
];
const OwlCarouselDemo = () => {
return (
<OwlCarousel className="owl-theme" loop margin={10} items={3}>
{items.map((item) => (
<div className="item" key={item.id}>
<h3>{item.text}</h3>
</div>
))}
</OwlCarousel>
);
};
export default OwlCarouselDemo;
And this is "package.json":
{
"name": "owlcarousel",
"version": "1.0.0",
"description": "",
"keywords": [],
"main": "src/index.js",
"dependencies": {
"loader-utils": "3.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-owl-carousel": "2.3.3",
"react-scripts": "5.0.1"
},
"devDependencies": {
"@babel/runtime": "7.13.8",
"typescript": "4.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
And here is the codesandbox example: https://codesandbox.io/s/owlcarousel-w37y5v?file=/src/OwlCarouselDemo.js:0-652