https://github.com/hamlim/react-media
A simple react component implementing window.matchMedia
https://github.com/hamlim/react-media
Last synced: about 1 year ago
JSON representation
A simple react component implementing window.matchMedia
- Host: GitHub
- URL: https://github.com/hamlim/react-media
- Owner: hamlim
- Created: 2017-05-28T16:18:37.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-02T13:18:51.000Z (over 8 years ago)
- Last Synced: 2025-04-05T00:47:47.482Z (about 1 year ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MatchMedia Component
This component is a simple wrapper around the `window.matchMedia` functionality,
as such it will only work (as intended) in browsers at or above the versions from this
table: https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia.
## Example:
```Javascript
import MatchMedia from '@matthamlin/react-media';
const MyComponent = props => (
{matches => matches ? () : ()}
);
```
## API:
MatchMedia accepts two props, the first being `media` which is a media query string, the
second is children which is a callback function that accepts one parameter that is a
boolean if the media query has matched or not.
## Contributing:
If you have found an issue or want to add features/tests feel free to open a PR
and explain what the PR is fixing/adding and I will work with you in getting that fix
merged into the master branch!
## Questions?
Feel free to open an issue and I will get back to you!