import * as React from 'react' ; import { createStyleSheet , setStyleSheetMedia } from '../general' ; export function useMediaStyleSheet ( content , getMediaQuery , size ) { const style = React . useRef < HTMLStyleElement > ( ) ; React . useEffect ( ( ) => { setSheetMedia ( ) ; } , [ size ] ) ; React . useEffect ( ( ) => { style . current = createStyleSheet ( content ) ; setSheetMedia ( ) ; } , [ ] ) ; function setSheetMedia ( ) { if ( style . current ) setStyleSheetMedia ( style . current , getMediaQuery ( size ) . map ( query => `(${ query })` ) . join ( ' and ' ) ) ; } }