How to conditionally render based on viewport size in React?

Posted by Andre Scott | Updated on

Want to conditionally render based on viewport size in React? Yes, you need to listen for resize event and update internal state on change. You can do it by adding event handler when component mounts.

Find Live demo here.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers