'use strict';

var React = require('react');

function useMedia(query) {
  return React.useSyncExternalStore(onStoreChange => {
    const mediaQueryList = window.matchMedia(query);
    mediaQueryList.addEventListener('change', onStoreChange);
    return () => {
      mediaQueryList.removeEventListener('change', onStoreChange);
    };
  }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
}

exports.useMedia = useMedia;
//# sourceMappingURL=useMedia.js.map
