A React hook to detect screen size based on media queries.
Install the package via npm:
npm install @tushar152003/use-media-query
Usage
Here’s how to use the useMediaQuery hook in your React components:
import useMediaQuery from '@tushar152003/use-media-query';
const MyComponent = () => {
const isMobile = useMediaQuery('(max-width: 768px)');
return (
<div>
{isMobile ? 'You are on a mobile device' : 'You are on a larger screen'}
</div>
);
};
export default MyComponent;