Frontend React.js

use-media

useMedia React sensor hook that tracks state of a CSS media query.

Depending on your testing setup, you may need to mock window.matchMedia on components that utilize the useMedia hook.

import useMedia from 'use-media';
// Alternatively, you can import as:
// import {useMedia} from 'use-media';

const Demo = () => {
// Accepts an object of features to test
const isWide = useMedia({minWidth: '1000px'});
...

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *