import * as React from 'react' ; import { useIsomorphicLayoutEffect } from './hooks' ; export type SetBlock = false | Promise < null > | null ; export type UnblockProps = { set : React . Dispatch < React . SetStateAction < SetBlock > > ; children : React . ReactNode ; } ; /**
 * Used to block rendering via its `set` prop. Useful for suspenseful effects.
 */ export const Block = ( { set } ) => { useIsomorphicLayoutEffect ( ( ) => { set ( new Promise ( ( ) => null ) ) ; return ( ) => set ( false ) ; } , [ ] ) ; return null ; } ; /**
 * Generic error boundary. Calls its `set` prop on error.
 */ export class ErrorBoundary extends React . Component < { set : React . Dispatch < any > ; } , { error : boolean ; } > { state = { error : false } ; static getDerivedStateFromError = ( ) => ( { error : true } ) ; componentDidCatch ( error ) { this . props . set ( error ) ; } render ( ) { return this . state . error ? null : this . props . children ; } }