Search code examples
reactjsmedia-queries

How do I get React to respond to media queries?


I would like a React component to be responsive to an external state, in this case the size of the viewport. Do I accomplish this internally to my component or do I do a media query which passes the viewport as a size property to the initial render?


Solution

  • Take a look at this project: https://github.com/wearefractal/react-responsive, it seems to be exactly what you need.