Tooltip cannot find ID of a React element rendered next to it
See original GitHub issueIssue description
- components:
Tooltip
- reactstrap version
5.0.0-alpha.4
- import method
umd
, not full version - react version
16.2.0
- bootstrap version
4.0.0-beta.3
What is happening?
Sometimes, when I render the attached code, I get this error: The target <target id> could not be identified in the dom, tip: check spelling
. However, I can’t get the codepen to reproduce this, but it consistently happens in my larger application base, which uses the same data flow. The bug occurs when the button in the codepen is pressed, but perhaps React functions differently in my case. I made a small change in the codepen, the bug is now reproduceable.
The full application is here: https://github.com/kenzierocks/OurTube/blob/master/client/js/navbar.tsx#L78
I can help set this up to run if needed, but it’s still in the middle of initial development
What should be happening?
It should render my custom tooltip properly, with no errors.
Code
Issue Analytics
- State:
- Created 6 years ago
- Reactions:19
- Comments:42 (7 by maintainers)
Top Results From Across the Web
Reactstrap tooltip causes an error: The target 'TooltipExample ...
In constructor, tooltipOpen should be false . And then, in componentDidMount, switch tooltipOpen from false to true. This is code:
Read more >Tooltips - reactstrap
reactstrap - easy to use React Bootstrap 4 components compatible with React 0.14.x and 15.
Read more >4 Ways to Show Tooltips in React with react-tooltip, Material UI ...
In this example, we start by importing the ReactTooltip component. We use ReactTooltip to render the content of the tooltip. We specify the...
Read more >Unknown Prop Warning - React
The unknown-prop warning will fire if you attempt to render a DOM element with a prop that is not recognized by React as...
Read more >Position in React Tooltip component - Syncfusion
Tooltips can be attached to 12 static locations around the target. On initializing the Tooltip, you can set the position property with any...
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
@yidingalan enzyme’s
mount
takes a second parameter;options
. Options has a property,attachTo
which is used to tell it where to mount the component. It’s not enough to add a div to the body, you have to then tell it to mount the component to that div.More information about mount and it’s options: https://github.com/airbnb/enzyme/blob/master/docs/api/mount.md#mountnode-options--reactwrapper
I was having this issue in my tests, which originally was:
This would give the error discussed.
To solve it (at least for my tests), I had to add the div to the body, since the tooltip tries to query the document. This was the fix:
I hope this can bring any insights to what you are experiencing.