Universal polyfill for match media API using Expo APIs on mobile
npm install @expo/match-media@expo/match-media
Universal polyfill for match media API using Expo APIs on mobile
---
TL;DR: Demo
Install @expo/match-media and expo-screen-orientation in your project.
``sh`
npx expo install @expo/match-media expo-screen-orientation
Import the polyfill at the top of your file before using the [window.matchMedia API][match-media].
`js`
import '@expo/match-media';
// use the match media API
What this does
- In the browser: Nothing
- In React Native apps: Polyfills the [matchMedia API][match-media] so you can use awesome libraries like react-responsive`.
The Expo source code is made available under the MIT license. Some of the dependencies are licensed differently, with the BSD license, for example.
---
[match-media]: https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia