question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't make it work onClick

See original GitHub issue

I might be very stupid but I can’t make it work… it’s been like an hour yet the tooltip keeps showing.

I have a button, and the tooltip.

  const tooltipRef = useRef(null);

<button
        className={styles.actionButton}
        onClick={() => {
          ReactTooltip.show(tooltipRef);
        }}
        data-tip=""
        data-event="click"
      >

<ReactTooltip type="error" ref={tooltipRef}>
        <span>Show happy face</span>
      </ReactTooltip>

I want to control when the tooltip displays or not, and I am not being able to control it. It automatically displays. What am I doing wrong?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

4reactions
talesdspcommented, Jun 22, 2020

This isn’t working because you passed the entire ref, instead of ref.current.

The following worked for me!

const idRef = useRef(null);

 <button
            ref={idRef} // here passes the ref
            data-tip="Copied!"
            onClick={() => ReactTooltip.show(idRef.current)} // here passes the ref.current
          >
            
          </button>
          <ReactTooltip
            type="success"
            event="click"
            eventOff="blur"
            delayShow={100}
            delayHide={500}
            place="bottom"
          />
1reaction
JorgeSivilcommented, May 27, 2020

Yeah that’s what actually happened to me. https://www.cssportal.com/css-tooltip-generator/ and that’s it haha

The problem is that I only found this library, or other bigger libraries that have a lot of things that I don’t need now, like Reactstrap or material UI

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript button onclick not working - Stack Overflow
Ran into this problem myself so I can confirm something's not right. The difference is that I am generating the DOm Element at...
Read more >
onclick function() doesn't work... - Sololearn
in the html i code: Hello A in the js page, i code: function click(){ document.getElementById("h1. ... onclick function() doesn't work.
Read more >
React onClick event handlers: A complete guide
Learn the basics of React's onClick event handler, including event listening, onClick buttons, synthetic events, custom events, and more.
Read more >
Onclick not working - JavaScript - SitePoint Forums
whenever I use onclick in javascript (not with onclick attribute in html) it doesn't work. I've never been able to get it to...
Read more >
Cant get onClick event to work for changing posts , Reddit Client
Nothing I have tried is working. I am trying to change the subreddit when you click on a subreddit. full code : https://github.com/Emm…...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found