React-bootstrap: carousel doesn't autoplay

Created on 22 Jul 2016  路  3Comments  路  Source: react-bootstrap/react-bootstrap

this is the render function of my Carousel component:

render () {
    const {scenarios} = this.props
    return (
      <Carousel activeIndex={this.state.index}
                direction={this.state.direction}
                onSelect={this.handleSelect}
                indicators={this.state.indicators}
                interval={this.state.interval}
                slide={this.state.slide}
                wrap={this.state.wrap}
                pauseOnHover={this.state.pauseOnHover}>
        {scenarios.map(scenario => (
          <Carousel.Item key={scenario.id}>
            <div className="scenario-container">
              <ScenarioDescription scenario={scenario} />
            </div>
          </Carousel.Item>
        ))}
      </Carousel>
    )
  }

and this is the state where I set all those props:

this.state = {
      index: 0,
      direction: 'next',
      interval: 2,
      indicators: false,
      pauseOnHover: true,
      slide: true,
      wrap: true
    }

but the carousel wouldn't start autoplaying. any suggestions? am I missing something?

Most helpful comment

If you control the carousel by setting activeIndex, then it's not going to transition the active item on you. Refer to the carousel examples in the docs.

All 3 comments

If you control the carousel by setting activeIndex, then it's not going to transition the active item on you. Refer to the carousel examples in the docs.

I figured it out after a while. Thank you @taion and sorry for this :)

If you do this:

componentDidMount(){ this.setState({activeIndex:0}) }

It will start the sycle.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kastork picture kastork  路  3Comments

wzup picture wzup  路  3Comments

jquense picture jquense  路  3Comments

mikejonas picture mikejonas  路  3Comments

catalinux picture catalinux  路  3Comments