useMediaQuery
is a custom hook to help detecting whether a single media query
or multiple media queries individually match.
Learn more about the API and its backgrounds.
The useMediaQuery
hook returns an array of booleans, indicating whether the
given query matches or queries match.
Why an array? useMediaQuery
accepts both a string and an array of strings, but
will always return an array. This way, you can combine multiple media queries
which will be individually matched in a single call.
Keep in mind this API relies on the users browser support of
window.matchMedia
and will always returnfalse
if it is not supported or does not exist (e.g. during serverside rendering).
smaller than 1280px
rendering on something else, e.g. PWA