import { useEffect, useRef, useState } from "@wordpress/element"; import { toggleEqualHeight } from "../shared/helpFn"; import TemplateOne from "../shared/templates/templateCards/templateOne"; import { breakpoint, inArray } from "../../controls/controls"; const Render = ({ attributes, posts }) => { const { timelineLayout, uniqueId, equalHeightEnable, imagePosition, contentOrientation, postGridLayout, catTabCategoryPosition, } = attributes; const containerRef = useRef(null); useEffect(() => { setTimeout(() => { toggleEqualHeight(uniqueId, equalHeightEnable); }, 50); }, [equalHeightEnable, uniqueId, posts]); const [selectedPostId, setSelectedPostId] = useState(null); useEffect(() => { const handleClickOutside = (event) => { if (containerRef.current && !containerRef.current.contains(event.target)) { setSelectedPostId(null); } }; document.addEventListener("mousedown", handleClickOutside); return () => document.removeEventListener("mousedown", handleClickOutside); }, []); return (
{posts?.map((post) => { return (
setSelectedPostId(post?.post_id)} />
); })}
); }; export default Render;