I'm using tippyjs/react. Sometimes I only wish to render my component, and not the tooltip as well.
My solution seems like a bit of an anti-pattern:
{window.myVariable && <SomeComponent/>}
{!window.myVariable &&
<Tippy content={<div>hi</div>}>
<SomeComponent/>
</Tippy>
}
I'm looking for something like an attribute I can attach to Tippy e.g.
<Tippy showTip={!window.myVariable} content={<div>hi</div>}>
<SomeComponent/>
</Tippy>
Thanks
Yeah there's a few ways:
{window.myVariable ? (
<SomeComponent />
) : (
<Tippy content="Tooltip">
<SomeComponent />
</Tippy>
)}
false in onShow if you don't want to show itconst onShow = () => !window.myVariable
<Tippy onShow={onShow}>
<SomeComponent />
</Tippy>
.enable() / .disable() imperatively on the instance_I think there should be React-specific props for this however_: like isEnabled which is part of the state object. Maybe isVisible, too
I think this is a good idea to have a component prop that, if specified, takes control over tooltip visibility and can be modified by providing custom onShow, onHide method callbacks.
Thanks!
Does anyone know why this no longer works after updating?
<Tippy onShow={onShow}>
<SomeComponent />
</Tippy>
I just updated to
"@tippy.js/react": "^2.2.0",
"tippy.js": "^3.1.3",
@tippy.js/react@2 is dependent on tippy.js@4 (v4 major)
Also, there were breaking changes in v2 obviously, you can read the release notes to find out
Most helpful comment
@tippy.js/react@2is dependent ontippy.js@4(v4 major)Also, there were breaking changes in
v2obviously, you can read the release notes to find out