import weakMemo from '@emotion/weak-memoize'; import { useBrand } from './Brand'; import facepaint from 'facepaint'; const minWidth = (width: number) => `@media (min-width: ${width}px)`; const mapBreakpoints = ([key, value]: number[]) => minWidth(value); // NOTE: `breakpoints` come through context from the brand via const paint = weakMemo(>(breakpoints: TBreakpoints) => facepaint(Object.entries(breakpoints).map(mapBreakpoints)) ); export const useMediaQuery = () => { const { LAYOUT }: { LAYOUT: any } = useBrand(); return paint(LAYOUT.breakpoints); };