useMediaQuery
Custom hook that tracks the state of a media query using the [
Match Media API](https://developer.Installation
npx sse-tool add use-media-query
npm install sse-hooks
Usage
import { useMediaQuery } from "./{hooks file}";
const isSmallScreen = useMediaQuery("(max-width: 600px)");
// Use `isSmallScreen` to conditionally apply styles or logic based on the screen size.
import { useMediaQuery } from "sse-hooks";
const isSmallScreen = useMediaQuery("(max-width: 600px)");
// Use `isSmallScreen` to conditionally apply styles or logic based on the screen size.
API
Parameters
| Name | Type | Description |
|---|---|---|
| query | string | The media query to track. |
| options | UseMediaQueryOptions | The options for customizing the behavior of the hook (optional). |
Return Value
Returns boolean.
The current state of the media query (true if the query matches, false otherwise).