New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mobx-react-matchmedia

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-react-matchmedia

A React HOC with mediaqueries for responsive layout.

  • 1.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

MobX React MatchMedia

A React HOC with mediaqueries for responsive layout.

Travis Build Codecov Coverage Downloads npm node GitHub license

NPM


Install

npm i --save mobx-react-matchmedia

Usage

Define mobx observable breakpoints

import { observable } from 'mobx';

const breakpoints = observable({
  xs: '(max-width: 767px)',
  su: '(min-width: 768px)',
  sm: '(min-width: 768px) and (max-width: 991px)',
  md: '(min-width: 992px) and (max-width: 1199px)',
  mu: '(min-width: 992px)',
  lg: '(min-width: 1200px)',
});

Pass the breakpoints to the MatchMediaProvider

import { MatchMediaProvider } from 'mobx-react-matchmedia';

<MatchMediaProvider breakpoints={breakpoints}>
  <Test breakpoints={breakpoints} />
</MatchMediaProvider>

Pass the breakpoints as props to components and check if true/false

import { observer } from 'mobx-react';

const Test = observer(({ breakpoints }) => (
  <div>
    {breakpoints.sm ? 'YES' : 'NO'}
  </div>
));

Now resize the browser window to see the changes!

Contributing

If you want to contribute to the development, do not hesitate to fork the repo and send pull requests.

And don't forget to star the repo, I will ensure more frequent updates! Thanks!

Keywords

FAQs

Package last updated on 24 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc