import React , { cloneElement } from 'react' ; import { Text } from 'react-native' ; import { styles } from './styles' ; import type { EnhancerProps } from './types' ; const Enhancer = ( { children : Component = null , style } ) => { if ( Component === null || Component === undefined ) { return null ; } if ( typeof Component === 'string' ) { return < Text style = { [ styles . container , style ] } > { Component } < /Text>; } if ( typeof Component === 'object' ) { return cloneElement ( Component , { ... Component . props , style : [ styles . container , style , Component . props . style ] , } ) ; } return ( < Component style = { [ styles . container , style ] } / > ) ; } ; Enhancer . displayName = 'Enhancer' ; export default Enhancer ;