marcj / css-element-queries

CSS Element-Queries aka Container Queries. High-speed element dimension/media queries in valid css.
http://marcj.github.io/css-element-queries/
MIT License
4.27k stars 487 forks source link

TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. #295

Closed krishna-kapoor closed 4 years ago

krishna-kapoor commented 4 years ago

I'm using React.js and this is the error I get. Here is my code:

toggleDiv(id) { const elem = document.getElementById(id); const display = window.getComputedStyle(elem).getPropertyValue('display'); if (display === 'none') { elem.style.display = 'block'; return false; } else { elem.style.display = 'none'; return true; } }

Please tell me how the variable elem is not an element.

marcj commented 4 years ago

This issue tracker is not for help with your own code.

krishna-kapoor commented 4 years ago

Oh I'm sorry, I'm new to GitHub.