import React from 'react' ; export type RenderFCProp < Props = { } > = ( props ? : Props ) => React . ReactElement ; export type RenderProp < Props = { } > = RenderFCProp < Props > | React . ReactElement ; export type FalsyFCProps < Props = { } > = Props & { component ? : RenderProp < Props > ; fallback ? : React . ReactElement ; } ; property property example example export class FalsyFC < Props = { } > extends React . Component < FalsyFCProps < Props > > { public render ( ) { const { component , fallback , ... props } = this . props ; if ( ! component ) { return fallback || null ; } if ( React . isValidElement ( component ) ) { return React . cloneElement ( component , props ) ; } return React . createElement ( component as RenderFCProp < Props > , props as Props ) ; } }