I encountered a parsing error that I'm struggling to resolve while using React Bootstrap. The issue arises when I try to declare Components at the beginning of my code. Despite copying the Carousel code directly from the React-Bootstrap website, I am unable to run it locally due to this persistent problem.
The error message reads: "Line 4: Parsing error: Unexpected token, expected ",""
2 | import logo from './logo.svg';
3 | import './App.css';
> 4 | import { Carousel, Carousel.Item, Carousel.Caption } from 'react-bootstrap';
| ^
5 |
6 | class App extends Component {
7 | render() {
For reference, here is my complete code:
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { Carousel, Carousel.Item, Carousel.Caption } from 'react-bootstrap';
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
{/* <img src={logo} className="App-logo" alt="logo" />
{<p>
Edit <code>src/App.js</code> and save to reload.
</p> */}
<Carousel>
<Carousel.Item>
<img width={900} height={500} alt="900x500" src="/carousel.png" />
<Carousel.Caption>
<h3>First slide label</h3>
<p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img width={900} height={500} alt="900x500" src="/carousel.png" />
<Carousel.Caption>
<h3>Second slide label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img width={900} height={500} alt="900x500" src="/carousel.png" />
<Carousel.Caption>
<h3>Third slide label</h3>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
</Carousel.Caption>
</Carousel.Item>
</Carousel>;
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
</a>
</header>
</div>
);
}
}
export default App;