import { useEffect, useState, } from 'react';
/**
 * Returns a boolean to indicate if a media query is matched. Only triggers re-renders when the match changes.
 * @param {string} query A window.matchMedia parsable media query string
 * @returns {boolean} Does the query match the current media?
 */
var useMediaQuery = function (query) {
    var _a = useState(false), matches = _a[0], setMatches = _a[1];
    useEffect(function () {
        var handleQueryChange = function (event) { return setMatches(event.matches); };
        var mediaQueryList = window.matchMedia(query);
        // DDBEB-304 Use addListener instead of addEventListener for iPad support
        mediaQueryList.addListener(handleQueryChange);
        setMatches(mediaQueryList.matches);
        // DDBEB-304 Use removeListener instead of removeEventListener for iPad support
        return function () { return mediaQueryList.removeListener(handleQueryChange); };
    }, [
        query,
    ]);
    return matches;
};
export default useMediaQuery;
//# sourceMappingURL=useMediaQuery.js.map