Socket
Socket
Sign inDemoInstall

mobx-matchmedia

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mobx-matchmedia

MobX observable for window.matchMedia


Version published
Weekly downloads
6
decreased by-40%
Maintainers
1
Install size
4.60 kB
Created
Weekly downloads
 

Readme

Source

mobx-matchmedia

A MobX observable for window.matchMedia

Install

yarn add mobx-matchmedia
# or
npm i mobx-matchmedia

Simple Usage

import { autorun } from "mobx";
import { matchMedia } from "mobx-matchmedia";

autorun(() => {
  if (matchMedia("(prefers-color-scheme: dark)")) {
    console.log('Your OS is in dark mode');
  } else {
    console.log('Your OS is in light mode');
  }
});

React Usage

import React from "react";
import { observer } from "mobx-react-lite";
import { matchMedia } from "mobx-matchmedia";

const MyComponent = observer(() => (
  <div>
    Your OS is in
    {' '}
    {matchMedia('(prefers-color-scheme: dark)') ? 'dark' : 'light'}
    {' '}
    mode
  </div>
));

FAQs

Last updated on 24 Jan 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc