import React from 'react' ; import { RenderProp } from '../falsyFC/falsyFC.component' ; import { Text , TextProps , } from '../../../ui/text/text.component' ; export interface FalsyTextProps extends Omit < TextProps , 'children' > { component ? : RenderProp < TextProps > | React . ReactText ; } example example example export class FalsyText extends React . Component < FalsyTextProps > { public render ( ) { const { component , ... textProps } = this . props ; if ( ! component ) { return null ; } if ( React . isValidElement ( component ) ) { return React . cloneElement ( component , textProps as TextProps ) ; } if ( typeof component === 'function' ) { return React . createElement ( component , textProps as TextProps ) ; } return ( < Text { ... textProps } > { component } < /Text>); } }