I have a website created using vanilla Js. Now, I am trying to add React to it. I followed the steps from the official documentation (https://reactjs.org/docs/add-react-to-a-website.html). Everything works fine. I am able to use react in my project. But now, I need to use a react library (react-responsive-carousel).
I tried running npm install react-responsive-carousel
. But I am not able to import this in my React component.
I compile my react files using npx babel react-js --out-dir js --presets @babel/preset-env,@babel/preset-react --watch
. It compiles the react import statements into require statements and I get the error "Uncaught ReferenceError: require is not defined"
in tthe browser
How can I use react libraries in my project?