@tushar152003/use-media-query
v1.0.2
Published
This is used to detect the screen size
Downloads
2
Readme
@tushar152003/use-media-query
A React hook to detect screen size based on media queries.
Installation
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;