Created
December 10, 2020 07:24
-
-
Save Risyandi/ba7c96990f2401e0a4baedc278d1b4dd to your computer and use it in GitHub Desktop.
example swiper in react
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 {SwiperSlide, Swiper} from 'swiper/react'; | |
import SwiperCore, {Pagination, Autoplay} from 'swiper'; | |
SwiperCore.use([Pagination, Autoplay]); | |
const Home = (props) => { | |
const [banner, setBanner] = useState([]) | |
// get data from api | |
setbanner(API_DATA); | |
return ( | |
<Swiper | |
pagination={{clickable: true }}> | |
{ | |
banner.map((row, idx) => { | |
return ( | |
<SwiperSlide key={idx}> | |
<img src={row.urlImage} alt="images"/> | |
</SwiperSlide> | |
) | |
}) | |
} | |
</Swiper> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment