Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

410 B
Raw Blame
import {
  type PropsWithChildren,
  type ReactNode,
  useEffect,
  useState,
} from "react";

type Props = {
  ssrFallback: ReactNode;
};

export const ClientSideOnlyWrapper = ({
  children,
  ssrFallback,
}: PropsWithChildren<Props>) => {
  const [isClientSide, setIsClientSide] = useState(false);

  useEffect(() => {
    setIsClientSide(true);
  }, []);

  return isClientSide ? children : ssrFallback;
};