Get viewport/window height in ReactJS

How do I get the viewport height in ReactJS? In normal JavaScript I use window.innerHeight() but using ReactJS, I’m not sure how to get this information. My understanding is that ReactDOM.findDomNode() only works for components created. However this is not the case for the document or body element, which could give me height of the … Read more

Is there a way to detect if a browser window is not currently active?

I have JavaScript that is doing activity periodically. When the user is not looking at the site (i.e., the window or tab does not have focus), it’d be nice to not run. Is there a way to do this using JavaScript? My reference point: Gmail Chat plays a sound if the window you’re using isn’t … Read more