Files
agentic-dev/packages/core-ui/src/cookie-consent-banner/cookie-consent-banner-loader.tsx
2026-07-12 08:15:46 +00:00

27 lines
659 B
TypeScript

"use client";
import { useState, useEffect, type ComponentPropsWithoutRef } from "react";
import { CookieConsentBanner } from "./cookie-consent-banner";
export type CookieConsentBannerLoaderProps = ComponentPropsWithoutRef<
typeof CookieConsentBanner
>;
/**
* SSR-safe wrapper that renders null on the server and mounts
* <CookieConsentBanner> client-side only (after hydration).
*/
export function CookieConsentBannerLoader(
props: CookieConsentBannerLoaderProps,
) {
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
}, []);
if (!mounted) return null;
return <CookieConsentBanner {...props} />;
}