Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React boostrap carousel not working

I'm trying to create a simple carousel using react-bootstrap. This is the simple uncontrolled carousel I'm trying to create. https://react-bootstrap.github.io/components/carousel/

This is my code,

import React from 'react';
import Carousel1 from '../../../assets/FootTheBall_SignUpScreen_CarouselImage-01.png';
import Carousel2 from '../../../assets/FootTheBall_SignUpScreen_CarouselImage-02.png';
import Carousel3 from '../../../assets/FootTheBall_SignUpScreen_CarouselImage-03.png';
import Carousel4 from 
import Carousel from 'react-bootstrap/lib/Carousel';


    const Core = () => (
        <main className="core">
            <article className="left">
                <Carousel>
                    <Carousel.Item>
                        <img src={Carousel1} alt=""/>
                    </Carousel.Item>
                    <Carousel.Item>
                        <img src={Carousel2} alt=""/>
                    </Carousel.Item>
                    <Carousel.Item>
                        <img src={Carousel3} alt=""/>
                    </Carousel.Item>
                </Carousel>

            </article>
            <article className="right"></article>
        </main>

    );
    export default Core

The images get vertically stacked and no transition happens. What am I doing wrong here.

like image 289
Melissa Stewart Avatar asked May 14 '18 20:05

Melissa Stewart


People also ask

Does react-bootstrap come with CSS?

Because React-Bootstrap doesn't depend on a very precise version of Bootstrap, we don't ship with any included css. However, some stylesheet is required to use these components. How and which bootstrap styles you include is up to you, but the simplest way is to include the latest styles from the CDN. <!--

What does'carousel-caption'do in Bootstrap?

'carousel-caption' Change the underlying component CSS base class name and modifier class names prefix. This is an escape hatchfor working with heavily customized bootstrap css.

How do I control the sliding of the carousel component?

I handled it controlling the sliding using the activeIndex and onSelect properties for the Carousel component. You might also be able to control it using the onSlid or onSlide callback properties, but not sure.

Do I need previous/next controls and indicators with a carousel?

As such, you may need to use additional utilities or custom styles to appropriately size content. While carousels support previous/next controls and indicators, they’re not explicitly required. Add and customize as you see fit.


1 Answers

Did you linked the style files?

According to docs:

Because React-Bootstrap doesn't depend on a very precise version of Bootstrap, we don't ship with any included css. However, some stylesheet is required to use these components. How and which bootstrap styles you include is up to you, but the simplest way is to include the latest styles from the CDN.

For linking add following to index.html:

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
like image 119
StackedQ Avatar answered Oct 07 '22 08:10

StackedQ