Skip to content
Permalink
Browse files

fix: 🐛 add check for ssr

  • Loading branch information
kitos committed Sep 18, 2019
1 parent cbf8808 commit b67ddcab9f0f306862188a7471fdaa4c32f86e41
Showing with 47 additions and 45 deletions.
  1. +47 −45 src/components/tooltip/tooltip.js
@@ -49,50 +49,52 @@ let Arrow = styled.div`
`

export let Tooltip = ({ isOpen, className, children, referenceElement }) =>
ReactDOM.createPortal(
<Popper referenceElement={referenceElement}>
{({ ref, style, placement, arrowProps }) => {
let translateSign = placement === 'bottom' ? '-' : ''
typeof document !== 'undefined'
? ReactDOM.createPortal(
<Popper referenceElement={referenceElement}>
{({ ref, style, placement, arrowProps }) => {
let translateSign = placement === 'bottom' ? '-' : ''

return (
<Transition
unique
reset
items={isOpen}
from={{
transform: `translateY(${translateSign}30px) scale(0.9)`,
opacity: 0,
}}
enter={{ transform: `translateY(0) scale(1)`, opacity: 1 }}
leave={{
transform: `translateY(${translateSign}30px) scale(0.9)`,
opacity: 0,
}}
>
{transitionIsOpen =>
transitionIsOpen &&
(transitionStyle => (
<div
ref={ref}
style={style}
data-placement={placement}
className={className}
>
<Popover style={transitionStyle}>{children}</Popover>
return (
<Transition
unique
reset
items={isOpen}
from={{
transform: `translateY(${translateSign}30px) scale(0.9)`,
opacity: 0,
}}
enter={{ transform: `translateY(0) scale(1)`, opacity: 1 }}
leave={{
transform: `translateY(${translateSign}30px) scale(0.9)`,
opacity: 0,
}}
>
{transitionIsOpen =>
transitionIsOpen &&
(transitionStyle => (
<div
ref={ref}
style={style}
data-placement={placement}
className={className}
>
<Popover style={transitionStyle}>{children}</Popover>

<Arrow
{...{ ...arrowProps, placement }}
style={{
...arrowProps.style,
opacity: transitionStyle.opacity,
}}
/>
</div>
))
}
</Transition>
)
}}
</Popper>,
document.body
)
<Arrow
{...{ ...arrowProps, placement }}
style={{
...arrowProps.style,
opacity: transitionStyle.opacity,
}}
/>
</div>
))
}
</Transition>
)
}}
</Popper>,
document.body
)
: null

0 comments on commit b67ddca

Please sign in to comment.
You can’t perform that action at this time.