Created
May 1, 2020 05:06
-
-
Save Manntrix/cabf1f9312d47b21b2294c22ab6df6f6 to your computer and use it in GitHub Desktop.
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 axios from 'axios' | |
import AliceCarousel from 'react-alice-carousel'; | |
import "react-alice-carousel/lib/alice-carousel.css"; | |
import './App.css'; | |
export default class App extends Component { | |
constructor(props, context) { | |
super(props, context); | |
this.state = { | |
galleryItems: [], | |
}; | |
} | |
getData (){ | |
axios.get(`https://picsum.photos/v2/list?limit=6`, {}) | |
.then(res => { | |
const data = res.data | |
const img = data.map(m => | |
<img src={m.download_url} alt=""/> | |
) | |
this.setState({ | |
galleryItems: img | |
}) | |
}).catch((error) => { | |
console.log(error) | |
}) | |
} | |
responsive = { | |
0: { items: 1 }, | |
1024: { items: 2 }, | |
} | |
componentDidMount() { | |
this.getData() | |
} | |
render() { | |
return ( | |
<div> | |
<AliceCarousel | |
items={this.state.galleryItems} | |
responsive={this.responsive} | |
autoPlayInterval={2000} | |
autoPlayDirection="rtl" | |
autoPlay={true} | |
fadeOutAnimation={true} | |
mouseTrackingEnabled={true} | |
disableAutoPlayOnAction={true} | |
/> | |
</div> | |
) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment