Giter Club home page Giter Club logo

react-match-media's Introduction

React Match Media

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 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.0.0 - 16/Jan/2017

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

License

MIT

react-match-media's People

Contributors

ianks avatar viruschidai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.