import {forwardRef, useContext, useRef} from "react"; import {getRouterContext, Outlet} from "@tanstack/react-router"; import {motion, useIsPresent} from "framer-motion"; import {cloneDeep} from "lodash"; const AnimatedOutlet = forwardRef((_, ref) => { const RouterContext = getRouterContext(); const routerContext = useContext(RouterContext); const renderedContext = useRef(routerContext); const isPresent = useIsPresent(); if (isPresent) { renderedContext.current = cloneDeep(routerContext); } return ( ); }); export default AnimatedOutlet