https://github.com/streamich/react-use-media
react-media hook
https://github.com/streamich/react-use-media
Last synced: 11 months ago
JSON representation
react-media hook
- Host: GitHub
- URL: https://github.com/streamich/react-use-media
- Owner: streamich
- License: unlicense
- Created: 2018-11-03T15:22:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T17:28:04.000Z (over 2 years ago)
- Last Synced: 2025-07-23T04:29:42.992Z (11 months ago)
- Language: TypeScript
- Size: 364 KB
- Stars: 26
- Watchers: 1
- Forks: 4
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-use-media
[`react-media`](https://github.com/ReactTraining/react-media) using hooks.
```js
import {useMedia} from 'react-use-media';
const Demo = () => {
const isWide = useMedia({
minWidth: 1000,
});
return (
Screen is wide: {isWide ? '😃' : '😢'}
);
};
```
Or, prepare hook once.
```js
const useMedia = createUseMedia({
minWidth: 1000,
});
const Demo = () => {
const isWide = useMedia();
return (
Screen is wide: {isWide ? '😃' : '😢'}
);
};
```