All Projects → streamich → react-use-media

streamich / react-use-media

Licence: Unlicense license
react-media hook

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

react-use-media

react-media using hooks.

import {useMedia} from 'react-use-media';

const Demo = () => {
  const isWide = useMedia({
    minWidth: 1000,
  });

  return (
    <div>
      Screen is wide: {isWide ? '😃' : '😢'}
    </div>
  );
};

Or, prepare hook once.

const useMedia = createUseMedia({
  minWidth: 1000,
});

const Demo = () => {
  const isWide = useMedia();

  return (
    <div>
      Screen is wide: {isWide ? '😃' : '😢'}
    </div>
  );
};
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].