You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportconstusePrintMatchMedia=(): boolean=>{const[isPrinting,setIsPrinting]=useState(false);useEffect(()=>{consthandleMediaQueryEvent=(event: MediaQueryListEvent): void=>{setIsPrinting(event.matches);};constmediaQuery=window.matchMedia('print');// iOS <=13 has no support forfor addEventListener/removeEventListener on MediaQueryList,// but supports addListenerif(mediaQuery.addEventListener){mediaQuery.addEventListener('change',handleMediaQueryEvent);}elseif(mediaQuery.addListener){mediaQuery.addListener(handleMediaQueryEvent);}// Trigger on initial rendersetIsPrinting(mediaQuery.matches);return(): void=>{if(mediaQuery.removeEventListener){mediaQuery.removeEventListener('change',handleMediaQueryEvent);}elseif(mediaQuery.removeListener){mediaQuery.removeListener(handleMediaQueryEvent);}};},[]);returnisPrinting;};
Using beforeprint/afterprint, the layout visibly changes in the main browser window if you use this to adjust it. Using mediaqueries, it only changes in the print preview (but again, only in Chrome).
mui/material-ui#17595
The text was updated successfully, but these errors were encountered: