"use client";

import { PropsWithChildren, useEffect, useState } from "react";

/** جلوگیری از mismatch اسلایدر Swiper بین SSR و کلاینت */
export const ClientOnly = ({
  children,
  fallback = null,
}: PropsWithChildren<{ fallback?: React.ReactNode }>) => {
  const [mounted, setMounted] = useState(false);
  useEffect(() => {
    setMounted(true);
  }, []);
  if (!mounted) return <>{fallback}</>;
  return <>{children}</>;
};
