import React from "react"; class Carousel extends React.Component { state = { photos: [], active: 0 }; static getDerivedStateFromProps({ media }) { let photos = []; if (media && media.photos && media.photos.photo) { photos = media.photos.photo.filter(photo => photo["@size"] === "pn"); } return { photos }; } handleIndexClick = event => { this.setState({ active: +event.target.dataset.index }); }; render() { const { photos, active } = this.state; return (
animal
{photos.map((photo, index) => ( // eslint-disable-next-line animal thumbnail ))}
); } } export default Carousel;