I’m trying to test out the carousel but when I load the page it is blank.
I installed react bootstrap with npm.
The carousal code is from https://react-bootstrap.github.io/components.html#media-content. I looked at my web console and I don’t have any warnings or errors either.
carousal.js
import React, { Component } from 'react';
import {Carousel} from 'react-bootstrap';
class carousel extends Component {
render() {
return (
<Carousel>
<Carousel.Item>
<img width={900} height={500} alt="900x500" src={require('./images/cs_logo.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={require('./images/cs_logo.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={require('./images/cs_logo.png')}/>
<Carousel.Caption>
<h3>Third slide label</h3>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
</Carousel.Caption>
</Carousel.Item>
</Carousel>
);
}
}
export default carousel;
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import carousel from './carousal';
ReactDOM.render(<carousel/>,document.getElementById('root'));
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
<title>title</title>
</head>
<body>
<header>
<div id="nav"></div>
</header>
<div id="root" style="text-align: center; float: none"></div>
</body>
</html>
Advertisement
Answer
Found the solution. It is not Bootstrap related but rather how I was exporting and naming my components.
Components need to capitalized as stated here. Simple React component not rendering