Skip to content

Instantly share code, notes, and snippets.

@Manntrix
Created May 1, 2020 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Manntrix/cabf1f9312d47b21b2294c22ab6df6f6 to your computer and use it in GitHub Desktop.
Save Manntrix/cabf1f9312d47b21b2294c22ab6df6f6 to your computer and use it in GitHub Desktop.
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