diff --git a/src/components/wrapper/ClientSideWrapper.tsx b/src/components/wrapper/ClientSideWrapper.tsx index 212f831..0d0c052 100644 --- a/src/components/wrapper/ClientSideWrapper.tsx +++ b/src/components/wrapper/ClientSideWrapper.tsx @@ -3,7 +3,7 @@ import clsx from 'clsx' import { AnimatePresence, motion } from 'framer-motion' import { usePathname } from 'next/navigation' -import React from 'react' +import React, { useRef } from 'react' type Props = { children: React.ReactNode @@ -12,15 +12,28 @@ type Props = { function ClientSideWrapper({ children, className = 'h-full' }: Props) { const pathname = usePathname() + const isFirstMount = useRef(true) + const prevPathname = useRef(pathname) + + // تشخیص اولین mount + const isInitial = isFirstMount.current + if (isFirstMount.current) { + isFirstMount.current = false + } + + // تشخیص تغییر pathname + const pathnameChanged = prevPathname.current !== pathname + prevPathname.current = pathname return ( - + {children}