Skip to content

Commit

Permalink
chore: disable prefetch for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jul 21, 2024
1 parent d9bfd9f commit 97d6fbf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/hook/use-breakpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useWindowSize } from './use-window-size'

const rawBreakpoints = breakpoints.map(toRaw)

export function useBreakpoint (mediaBreakpoints) {
export function useBreakpoint (mediaBreakpoints = [0, 1, 2, 3]) {
const { width } = useWindowSize()

const index = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/patterns/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Layout = ({
component = Box,
...props
}) => {
const breakpoint = useBreakpoint([0, 1, 2, 3])
const breakpoint = useBreakpoint()
const toolbarHeight = TOOLBAR_HEIGHTS[breakpoint]

useEffect(() => {
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/hoc/with-link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global IntersectionObserver */

import { useBreakpoint } from 'components/hook'
import { ArrowUpRight as ExternalIcon } from 'react-feather'
import React, { useRef, useState, useEffect } from 'react'
import { useLocation } from '@gatsbyjs/reach-router'
Expand Down Expand Up @@ -110,6 +111,7 @@ export const withLink = Component => {
icon,
...props
}) => {
const breakpoint = useBreakpoint()
const [isIntersecting, setIsIntersecting] = useState(false)
const location = useLocation()
const isInternal = isInternalLink(href)
Expand All @@ -135,6 +137,7 @@ export const withLink = Component => {
}

const isPrefetch =
breakpoint > 1 &&
prefetch &&
href !== '/' &&
!href.startsWith('/docs') &&
Expand Down

0 comments on commit 97d6fbf

Please sign in to comment.