Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump 3.0.0 #15

Merged
merged 1 commit into from
Oct 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 30 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# react-simple-matchmedia
React component used for matching media queries.
(It doesn't exists in DOM if media query is not matched)
Under the hood it uses browser's `window.matchMedia`.
`React hook` used for matching media queries.
(It doesn't render in DOM if media query is not matched)
It uses browser's `window.matchMedia`.


[![](https://img.shields.io/circleci/project/github/RedSparr0w/node-csgo-parser.svg)](https://circleci.com/gh/egdbear/react-simple-matchmedia)
Expand All @@ -16,9 +16,15 @@ Under the hood it uses browser's `window.matchMedia`.
$ yarn add react-simple-matchmedia
```

or

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

### Usage

[![Edit 1z02pl6xqq](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/1z02pl6xqq)
[![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:
Expand All @@ -32,35 +38,34 @@ $ yarn add react-simple-matchmedia

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

// somewhere in render
const MediaQueryComponent = () => {
const matched = useReactSimpleMatchMedia('phone');

<SimpleMatchMedia media="phone">
I am only able to be visible and rendered in DOM on phone screen!
</SimpleMatchMedia>
```
#### With custom query:
return (
<Fragment>
{ matched && '<div>I am only visible and rendered in DOM on phone screen!</div>'}
</Fragment>
);
}

```
<SimpleMatchMedia media="(min-width: 200px) and (max-width: 600px)">
I am only able to be visible and rendered in DOM on screen with query of (min-width: 200px) and (max-width: 600px)!
</SimpleMatchMedia>

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

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

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

```
<SimpleMatchMedia media="(min-width: 600px)">
{matched =>
matched ? (
I am matching (min-width: 600px)
) : (
"Warning. I am not maching (min-width: 600px)"
)
}
</SimpleMatchMedia>
```

###
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-simple-matchmedia",
"version": "2.2.2",
"version": "3.0.0",
"description": "React component used for matching media queries",
"main": "build/index.cjs.js",
"module": "build/index.es.js",
Expand Down