import React, { useState, useEffect } from "react"; import StorageImage from "./StorageImage"; import { Row, Col, Carousel } from "react-bootstrap"; import { useHistory, useParams, useLocation } from "react-router-dom"; import { useSelector } from "react-redux"; const PhotoViewer = () => { const { userID, n } = useParams(); const users = useSelector((state) => state.users); const photos = users.find((user) => user.userID === userID).photos; const [activeIndex, setActiveIndex] = useState(Number(n)); const history = useHistory(); const location = useLocation(); useEffect(() => { const locArr = location.pathname.split("/"); const index = Number(locArr.pop()); setActiveIndex(index); }, [location]); const handleSelect = (selectedIndex, e) => { history.push(`/fakebook/photo/${userID}/${selectedIndex}`); }; return ( {photos.map((photo, index) => { return ( ); })} ); }; export default PhotoViewer;