import React, { useState, useRef, useEffect } from "react"; import { ArrowButton} from "./ArrowButton"; export function FeedItemPhotos({ photos }: any) { const photoRef = useRef(0); const [photosX, setPhotosX] = useState(0); const [refLoaded, setRefLoaded] = useState(false); const [selectedPhoto, setSelectedPhoto] = useState(0); const [min_x, setMinX] = useState( -((((photoRef.current as any).width || 0) + 2) * (photos.length - 1)) ); useEffect(() => { if (photoRef) setRefLoaded(true); }, [photoRef]); useEffect(() => { if ((photoRef.current as any)?.width > 0) setMinX(-((((photoRef.current as any).width || 0) + 2) * (photos.length - 1))); }); const slideButtonEvent = (x: any) => { if (x < min_x) setPhotosX(min_x); else if (x > 0) setPhotosX(0); else setPhotosX(x); }; return (