useMatchMedia
Use window.matchMedia()
to determine if the document matches the media query string.
API
function useMatchMedia(query: string, defaultValue?: boolean): boolean;
Example
(max-width: 1200px): false
import React from "react";
import { useMatchMedia } from "@lilib/hooks";
function Example() {
const matches = useMatchMedia("(max-width: 1200px)");
return <>(max-width: 1200px): {matches.toString()}</>;
}
export default Example;