Is it possible to conditionally render only the component?
See original GitHub issueI’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
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
7 Ways to Implement Conditional Rendering in React ...
This article covers seven different ways to implement conditional rendering in React applications with practical examples and performance ...
Read more >Six methods to achieve conditional rendering in React - Flexiple
Conditional rendering in React works the same way conditions work in JavaScript. Use JavaScript operators like if, and let React update the UI ......
Read more >React conditional rendering: 9 methods with examples
In React, conditional rendering refers to the process of delivering elements and components based on certain conditions. There's more than one ...
Read more >is there anyway to conditionally render a React component ...
Yes, components may be rendered conditionally. Inside your render() {} method you can do something like... render() { if (condition1) ...
Read more >How to Show Components Conditionally in React | Pluralsight
Introduction · Option 1 - If Component · Option 2 - IIFE · Option 3 - Variable · Option 4 - Render Function...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yeah there’s a few ways:
falseinonShowif you don’t want to show it.enable()/.disable()imperatively on the instanceI think there should be React-specific props for this however: like
isEnabledwhich is part of the state object. MaybeisVisible, too@tippy.js/react@2is dependent ontippy.js@4(v4 major) Also, there were breaking changes inv2obviously, you can read the release notes to find out