Get the current screen height in React.js?

itsbambi asked this question 1 year, 5 months ago
itsbambi on Dec 14, 2021 · Edited

In my React.js component, I'd like to conditionally render some elements depending on the screen height.

How do I get the current height of the user's screen? Is there a pure JavaScript solution?

2 suggested answers
looper003 on Dec 22, 2021

window.innerHeight will do the trick for you.

0 replies
suparman21 on Dec 22, 2021

This returns the height of the browser in pixels.

0 replies