import React, { useEffect, useRef, useState } from "react"; import VideoButton from "/home/clyde/Code/shiloh/Components/Buttons/video-button.jsx"; import Link from "next/link"; const Section = ({ videoUrl, text, videoId, buttonOneText, buttonTwoText, buttonLink = "/", // add a default value, }) => { const videoRef = useRef(null); const [isPlaying, setIsPlaying] = useState(false); useEffect(() => { const options = { root: null, rootMargin: "0px", threshold: 0.5, }; const observer = new IntersectionObserver((entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { setIsPlaying(true); videoRef.current?.play(); } else { setIsPlaying(false); videoRef.current?.pause(); } }); }, options); if (videoRef.current) { observer.observe(videoRef.current); } return () => { if (videoRef.current) { observer.unobserve(videoRef.current); } }; }, []); return (