ReactTraining / react-media

CSS media queries for React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to check orientation with this?

sarabs3 opened this issue · comments

This library is just a wrapper around the window.matchMedia API, meaning you can use any feature supported by media queries.

To answer your question, you could use the orientation feature:

<Media query="(orientation: landscape)">
  {isLandscape =>
    isLandscape
      ? <p>I'm in landscape mode</p>
      : <p>I'm in portait mode</p>
  }
</Media>

Disclaimer: I didn't actually run the code above, so please forgive me if there are any typos or anything 😅

@sarabs3 I'll consider this solved. Let me know if anything remains unclear!