/**
 * TEAM: frontend_infra
 * @flow strict
 */

import * as React from "react";
import useOnClientSideOnly from "./tools/useOnClientSideOnly";

// Thin wrapper for Suspense that renders client-side only allowing it to work with SSR
export default function Suspense(
  props: React.ElementConfig<typeof React.Suspense>
): React.Node {
  const {isOnClient} = useOnClientSideOnly();

  return isOnClient ? <React.Suspense {...props} /> : props.fallback ?? null;
}
