Skip to content

Commit

Permalink
attempt to prevent excess renders in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarow committed Jul 17, 2024
1 parent 1c8652b commit 1b8271f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/app/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ const MyApp = (appProps: AppPropsWithGridSwitch) => {
<Notifications transitionDuration={500} />
<ConditionalReactQueryDevtool />
<Analytics />
<SpeedInsights />
<DonateModal />
</Providers>
<SpeedInsights />
</>
)
}
Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/providers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ export const Providers = ({ children, session }: ProviderProps) => {
// )

const mantineTheme = useMemo(() => ({ ...appTheme, fontFamily: fontWorkSans.style.fontFamily }), [])

const mantineCache = useMemo(() => appCache, [])
return (
<MantineProvider withGlobalStyles withNormalizeCSS theme={mantineTheme} emotionCache={appCache}>
<MantineProvider withGlobalStyles withNormalizeCSS theme={mantineTheme} emotionCache={mantineCache}>
{/* <ConsentProvider options={consentOptions}> */}
<SessionProvider session={session}>
<EditModeProvider>
Expand Down
25 changes: 15 additions & 10 deletions packages/ui/hooks/useScreenSize.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { em, useMantineTheme } from '@mantine/core'
import { useMediaQuery } from '@mantine/hooks'
import { useMemo } from 'react'

export const useScreenSize = () => {
const theme = useMantineTheme()
const isLandscape = useMediaQuery(`(orientation: landscape) and (max-height: ${em(430)})`)
return {
isMobile: useMediaQuery(`(max-width: ${theme.breakpoints.xs})`) || isLandscape,
isTablet:
useMediaQuery(`(max-width: ${theme.breakpoints.sm}) and (min-width: ${theme.breakpoints.xs})`) &&
!isLandscape,
isLandscape,
isSmallLandscape: useMediaQuery(
`(orientation: landscape) and (max-height: ${em(376)}) and (max-width: ${theme.breakpoints.xs})`
),
}

const isMobile = useMediaQuery(`(max-width: ${theme.breakpoints.xs})`) || isLandscape
const isTablet =
useMediaQuery(`(max-width: ${theme.breakpoints.sm}) and (min-width: ${theme.breakpoints.xs})`) &&
!isLandscape
const isSmallLandscape = useMediaQuery(
`(orientation: landscape) and (max-height: ${em(376)}) and (max-width: ${theme.breakpoints.xs})`
)

const screenSizes = useMemo(
() => ({ isMobile, isTablet, isLandscape, isSmallLandscape }),
[isMobile, isTablet, isLandscape, isSmallLandscape]
)
return screenSizes
}

0 comments on commit 1b8271f

Please sign in to comment.