import React, { useState, useEffect } from "react"; import { Spinner, Row, Col, Button } from "react-bootstrap"; //Videos function that handles the content of Videos function Videos() { const [isLoading, setLoading] = useState(true); const [videos, setVideos] = useState([]); const [currentVideoIndex, setCurrentVideoIndex] = useState(0); //Create const that gets YouTube Api data and build video links from data const getYTVideoLink = async () => { try { const response = await fetch("https://express-api-neinhills.onrender.com/youtube"); const json = await response.json(); const videoLinks = await json.items.map(item => "https://www.youtube.com/embed/" + item.id.videoId); const videoiframe = await videoLinks.map(link => ); setVideos(videoiframe); } catch (error) { console.error(error); } finally { setLoading(false); } }; //Handle the state of currentVideoIndex to get the previous video const handlePrevClick = () => { if (currentVideoIndex > 0) { setCurrentVideoIndex(currentVideoIndex - 1); } }; //Handle the state of currentVideoIndex to get the next video const handleNextClick = () => { if (currentVideoIndex < videos.length - 1) { setCurrentVideoIndex(currentVideoIndex + 1); } }; useEffect(() => { getYTVideoLink(); }, []); //Return data to display on the website, also takes data from vidoes to display on the website return (