How can I render react component within tooltip?
See original GitHub issueHi and thanks for sharing this library.
I’ve been testing a few and it is the only one that work.
One thing I need to do is to passe react-component within the tooltip, but the data-tip
is the only prop
I know that can be added in the tooltip
and it expect a string
.
Is it possible to render react-component within tooltips?
Thanks in advance
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:11 (2 by maintainers)
Top Results From Across the Web
How can I render react component within tooltip? #467 - GitHub
@kopax Yes I found that it does work with a react component. You could create a simple functional component like so: function Tooltip(props)...
Read more >React Tooltip using Components - Stack Overflow
1 Answer 1 · You should use the data-html={true} prop to let the react-tooltip know that the value passed to data-tip is actually...
Read more >How To Make an Extremely Reusable Tooltip Component ...
It takes everything inside a <Tooltip> component and moves it inside a div with Tooltip-Wrapper class by using props.children; It controls what ...
Read more >Building a Tooltip Component with React - Medium
If the button is all the way at the bottom, then render the tooltip above it. First things first, let's create the DOM...
Read more >4 Ways to Show Tooltips in React with react-tooltip, Material UI ...
We use ReactTooltip to render the content of the tooltip. We specify the id property for the tooltip and a content. The place...
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 FreeTop 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
Top GitHub Comments
I was able to pass a React Component as the child of the tooltip by constructing a Tooltip component based on react-tooltip. Here is what I did:
The key is to construct a unique Id for each tooltip that will appear on the same page to prevent collisions. I did that by using the props I pass to the Tooltip component. So at the top of the Tooltip component, I put: const tooltipId =
${props.content}+${props.title}+${props.theme}+${props.place}
(please note that I put backticks around the templated string - hard to format this with markdown)This allows me to render react components within my Tooltip component like so:
I hope this helps you!
Thanks for following up on this and my apologies for the delay. I still would like to do a PR to update the doc with the code snippet, and my goal is to do it over the weekend.