'use client'; import { Loader } from 'next/dist/shared/lib/dynamic'; import dynamic from 'next/dynamic'; import { FC, PropsWithChildren, memo } from 'react'; import MobileSwitchLoading from '@/features/MobileSwitchLoading'; import { useIsMobile } from '@/hooks/useIsMobile'; interface ClientResponsiveLayoutProps { Desktop: FC; Mobile: Loader; } const ClientResponsiveLayout = ({ Desktop, Mobile }: ClientResponsiveLayoutProps) => { const MobileComponent = dynamic(Mobile, { loading: MobileSwitchLoading, ssr: false, }) as FC; const Layout = memo(({ children }) => { const mobile = useIsMobile(); return mobile ? {children} : {children}; }); Layout.displayName = 'ClientLayout'; return Layout; }; export default ClientResponsiveLayout;