# react-simple-matchmedia

> React component used for matching media queries

Latest version **3.3.0** (published 2021-10-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-simple-matchmedia
pnpm add react-simple-matchmedia
yarn add react-simple-matchmedia
bun add react-simple-matchmedia
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.0 |
| Published | 2021-10-21 |
| First published | 2018-12-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | egdbear |
| Maintainers | egdfer |
| Keywords | window.matchMedia, react-component, react, react-simple-matchmedia, matchmedia, useWindowMedia |

## Links

- npm: https://www.npmjs.com/package/react-simple-matchmedia
- Repository: https://github.com/egdbear/react-simple-matchmedia
- Homepage: https://github.com/egdbear/react-simple-matchmedia#readme
- Issues: https://github.com/egdbear/react-simple-matchmedia/issues
- npm.io page: https://npm.io/package/react-simple-matchmedia

## Dependencies (1)

- [standard-version](https://npm.io/package/standard-version.md) ^9.3.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.3.0 (latest) — 2021-10-21
- 3.1.0 — 2021-01-31
- 3.0.2 — 2019-10-06
- 3.0.1 — 2019-10-06
- 3.0.0 — 2019-10-06
- 2.2.2 — 2019-05-02
- 2.2.0 — 2018-12-14
- 2.1.3 — 2018-12-08
- 2.1.2 — 2018-12-08
- 2.1.1 — 2018-12-08
- 2.0.0 — 2018-12-07

## README

# react-simple-matchmedia
[![](https://img.shields.io/circleci/project/github/RedSparr0w/node-csgo-parser.svg)](https://circleci.com/gh/egdbear/react-simple-matchmedia)
![install size](https://badgen.net/bundlephobia/minzip/react-simple-matchmedia)
[![](https://img.shields.io/packagecontrol/dm/GitGutter.svg)](https://www.npmjs.com/package/react-simple-matchmedia)  

`React hook` used for matching media queries.  
It uses browser's `window.matchMedia`.  
With SSR support :rocket:  



### Install

```sh
$ yarn add react-simple-matchmedia
```

or

```sh
$ npm i react-simple-matchmedia
```

### Usage

[![Edit hopeful-jennings-cho5q](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/hopeful-jennings-cho5q?fontsize=14)


#### Pre-defined media queries:

| media | value |
| ------ | ------ |
| phone | (min-width: 320px) and (max-width: 568px) |
| tablet | (min-width : 768px) and (max-width : 1024px) |
| desktop | (min-width : 1224px) |


#### With pre-defined query:
```
import useReactSimpleMatchMedia from 'react-simple-matchmedia'

const MediaQueryComponent = () => {
  const matched = useReactSimpleMatchMedia('phone');

  return (
    <Fragment>
      { matched && <div>I am only visible and rendered in DOM on phone screen!</div>}
    </Fragment>
  );
}

```

### With custom queries:
```
import useReactSimpleMatchMedia from 'react-simple-matchmedia'

const MediaQueryComponent = () => {
  const matched = useReactSimpleMatchMedia('(min-width: 600) and (max-width: 1200px)');

  return (
    <Fragment>
      { matched && <div>I am only visible and rendered in DOM between 600px and 1200px</div>}
    </Fragment>
  );
}

```

###

Enjoy and have fun!

---
_Source: https://npm.io/package/react-simple-matchmedia · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
