useMatchMedia
The useMatchMedia
hook allows you to listen for changes to a specified media query and execute a callback function whenever the change event for the media query is fired.
Add the utility
Return
This hook returns void
.
Parameters
mediaQuery
: A string representing the media query to match (e.g.,(max-width: 600px)
).callback
: A function that will be called with a boolean argument indicating whether the media query matches. This function can also return a promise.