Last active
October 4, 2018 11:20
-
-
Save DZuz14/7f51fff088969d56d12928b0b9045735 to your computer and use it in GitHub Desktop.
Incrementing currentIndex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import Slide from '../slide' | |
import LeftArrow from '../left-arrow' | |
import RightArrow from '../right-arrow' | |
export default class Slider extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
images: [ | |
"https://s3.us-east-2.amazonaws.com/dzuz14/thumbnails/aurora.jpg", | |
"https://s3.us-east-2.amazonaws.com/dzuz14/thumbnails/canyon.jpg", | |
"https://s3.us-east-2.amazonaws.com/dzuz14/thumbnails/city.jpg", | |
"https://s3.us-east-2.amazonaws.com/dzuz14/thumbnails/desert.jpg", | |
"https://s3.us-east-2.amazonaws.com/dzuz14/thumbnails/mountains.jpg", | |
"https://s3.us-east-2.amazonaws.com/dzuz14/thumbnails/redsky.jpg", | |
"https://s3.us-east-2.amazonaws.com/dzuz14/thumbnails/sandy-shores.jpg", | |
"https://s3.us-east-2.amazonaws.com/dzuz14/thumbnails/tree-of-life.jpg" | |
], | |
currentIndex: 0 | |
} | |
} | |
goToPrevSlide = () => { | |
} | |
goToNextSlide = () => { | |
this.setState(prevState => ({ | |
currentIndex: prevState.currentIndex + 1 | |
})); | |
} | |
render() { | |
return ( | |
<div className="slider"> | |
<Slide /> | |
<LeftArrow | |
goToPrevSlide={this.goToPrevSlide} | |
/> | |
<RightArrow | |
goToNextSlide={this.goToNextSlide} | |
/> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment