Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-match-media

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-match-media

A react component allows you to conditionally render your components based on media queries.

  • 2.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
32
decreased by-3.03%
Maintainers
1
Weekly downloads
 
Created
Source

React Match Media

Downloads

A React component that allows you to conditionally render your components based on media queries for your responsive website.

Underline it uses window.matchMedia

alt tag

Usage

Install

npm i react-match-media

Use it in your code (es6 syntax)

import React from 'react';
import ReactDOM from 'react-dom';
import { MatchMediaHOC } from 'react-match-media';

const ComponentForBigScreen = MatchMediaHOC(SomeComponent, '(min-width: 800px)');
const ComponentForSmallScreen = MatchMediaHOC(SomeComponent, '(max-width: 500px)');

ReactDOM.render(
  <div className="example">
    <SomeElementAlwaysRendered />
    <ComponentForBigScreen />
    <ComponentForSmallScreen />
  </div>,
  document.getElementById('root')
)

For more, see the examples

Supported browsers

  • IE10 and above
  • All other major browsers

For older browsers, you need to polyfill window.matchMedia. For more, see Can I Use matchMedia

Development of this component

Start the example

npm install
npm start
open http://localhost:3000

And then you can edit the source code, hotreloading is enabled, so you can see the changes immediatly

Linting

npm run lint

Testing

npm run test

To generate distribution code

npm run build

Changelog

v2.2.0 - 25/April/2018

Used PropTypes from 'prop-types' package

v2.0.0 - 16/Jan/2017

Introduced a MatchMediaHOC high order component to replace the previous MatchMedia component.

License

MIT

Keywords

FAQs

Package last updated on 07 Feb 2019

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