# react-responsive-mixin

> Mixin to develop responsive react components

Latest version **0.4.0** (published 2016-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-responsive-mixin
pnpm add react-responsive-mixin
yarn add react-responsive-mixin
bun add react-responsive-mixin
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2016-09-01 |
| First published | 2014-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 95 |
| Author | Kiran Abburi |
| Maintainers | akiran |
| Keywords | react, media-query, responsive, react-component |

## Links

- npm: https://www.npmjs.com/package/react-responsive-mixin
- Repository: https://github.com/akiran/react-responsive-mixin
- Issues: https://github.com/akiran/react-responsive-mixin/issues
- npm.io page: https://npm.io/package/react-responsive-mixin

## Dependencies (3)

- [json2mq](https://npm.io/package/json2mq.md) ^0.2.0
- [enquire.js](https://npm.io/package/enquire.js.md) ^2.1.1
- [can-use-dom](https://npm.io/package/can-use-dom.md) ^0.1.0

## 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

- 0.4.0 (latest) — 2016-09-01
- 0.3.5 — 2015-06-08
- 0.3.4 — 2015-05-28
- 0.3.3 — 2015-02-03
- 0.3.2 — 2015-02-03
- 0.3.1 — 2015-01-23
- 0.3.0 — 2015-01-23
- 0.2.0 — 2015-01-15
- 0.1.1 — 2014-11-24
- 0.1.0 — 2014-11-23

## README

# react-responsive-mixin

> react-responsive-mixin makes building responsive components easy

This mixin adds method called `media()` to the react component.
This is a wrapper around [enquire.js](http://wicky.nillia.ms/enquire.js/)

### [Demo](http://webrafter.com/opensource/react-responsive-mixin)

### Usage
```javascript
this.media(query, handler)
```
##### `query`
query is a media query definition either in string or object format.
This mixin internally uses [json2mq](https://github.com/akiran/json2mq) to convert media query from object to string format.

##### `handler`
handler is a function that needs to be executed when media query matches. 
handler can also be an object according to [enquire.js](http://wicky.nillia.ms/enquire.js/#api) API

##### Example

```javascript
var React = require('react');
var ResponsiveMixin = require('react-responsive-mixin');

var Component = React.createClass({
  mixins: [ResponsiveMixin],
  getInitialState: function () {
    return { url: '/img/large.img' };
  },
  componentDidMount: function () {
    this.media({maxWidth: 600}, function () {
      this.setState({url: '/img/small.jpg'});
    }.bind(this));
    this.media({minWidth:601, maxWidth: 1024}, function () {
      this.setState({url: '/img/medium.jpg'});
    }.bind(this));
    this.media({minWidth: 1025}, function () {
      this.setState({url: '/img/large.jpg'});
    }.bind(this));
  },
  render: function () {
    return <img src={this.state.url} />;
  }
});

```

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