on-internet
← Community

offsetTop,offsetLeft and getBoundingClientRect() are not working in my React app

Stack Overflow ·

I'm working in react and I'm creating a button with a tooltip, but I can't place it. I mean I can't read the button's distance from the top and left. I tried offsetTop and offsetLeft and I got this error: "Uncaught TypeError: Cannot read property 'offsetWidth' of undefined" so I tried getBoundingClientRect() and all I got is another error: "Uncaught TypeError: elem.getBoundingClientRect is not a function". I'm passing the information from component to the second component by assigning the distances to the global variable and read it in this second component when I need to place it. This is my

Comments

Sign in or sign up to comment and upvote.

No comments yet.