Allow Tooltip factory to use string native components

old
Ezequiel Schwartzman 2016-12-02 13:03:16 -05:00
parent a8e1bb7668
commit b3f99348d4
2 changed files with 6 additions and 3 deletions

View File

@ -193,6 +193,8 @@ const tooltipFactory = (options = {}) => {
[theme[positionClass]]: theme[positionClass]
});
const isNative = typeof ComposedComponent === 'string';
return (
<ComposedComponent
{...other}
@ -200,7 +202,7 @@ const tooltipFactory = (options = {}) => {
onClick={this.handleClick}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
theme={theme}
{...isNative ? {} : {theme}}
>
{children ? children : null}
{visible && (

View File

@ -9,6 +9,7 @@ const TooltipStrong = Tooltip(({children, ...other}) => {
delete other.theme;
return <strong {...other}>{children}</strong>;
});
const TooltipStrongDirect = Tooltip('strong');
const TooltipTest = () => (
<section>
@ -27,9 +28,9 @@ const TooltipTest = () => (
<p>
Click this next word to show and hide on click:
{' '}
<TooltipStrong tooltip='This is a auto show tooltip' tooltipShowOnClick>
<TooltipStrongDirect tooltip='This is a auto show tooltip' tooltipShowOnClick>
oh hai
</TooltipStrong>
</TooltipStrongDirect>
{' '}. This is useful for mobile!
</p>
</section>