next.js/packages/next/src/shared/lib/lazy-dynamic/dynamic-bailout-to-csr.tsx
dynamic-bailout-to-csr.tsx22 lines509 B
'use client'

import type { ReactElement } from 'react'
import { BailoutToCSRError } from './bailout-to-csr'

interface BailoutToCSRProps {
  reason: string
  children: ReactElement
}

/**
 * If rendered on the server, this component throws an error
 * to signal Next.js that it should bail out to client-side rendering instead.
 */
export function BailoutToCSR({ reason, children }: BailoutToCSRProps) {
  if (typeof window === 'undefined') {
    throw new BailoutToCSRError(reason)
  }

  return children
}
Quest for Codev2.0.0
/
SIGN IN