api / frontend /ClientOnly.tsx
gary-boon
Deploy Visualisable.ai backend with API protection
c6c8587
raw
history blame
429 Bytes
"use client";
import { useEffect, useState } from "react";
interface ClientOnlyProps {
children: React.ReactNode;
fallback?: React.ReactNode;
}
export default function ClientOnly({ children, fallback = null }: ClientOnlyProps) {
const [hasMounted, setHasMounted] = useState(false);
useEffect(() => {
setHasMounted(true);
}, []);
if (!hasMounted) {
return <>{fallback}</>;
}
return <>{children}</>;
}