import React from "react"; import { AnimatePresence, motion } from "framer-motion"; import { useSelector } from "react-redux"; // Sets animation and styles for all sidebar pages function ActivePage({ activePageName, children, className }) { const activeSlidebarPage = useSelector( (state) => state.sidebarReducer.activePage ); let variant = { hidden: { x: activePageName === "chatList" ? 0 : "40rem", }, visible: { x: 0, transition: { duration: 0.2, }, }, exit: { x: activePageName === "chatList" ? "-40rem" : "40rem", transition: { delay: activePageName === "chatList" ? 0.1 : 0, duration: 0.2, }, }, }; return ( {activeSlidebarPage === activePageName && ( {children} )} ); } export default ActivePage;