Created
June 8, 2021 12:56
-
-
Save technikhil314/a99a4e1a5847c7edc3f3629dfa8a42da to your computer and use it in GitHub Desktop.
Gatsby disable prefetch link component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { Link } from 'gatsby' | |
import { Link as RouterLink } from '@reach/router' | |
function MyLink({ children, to, prefetch, ...rest }) { | |
if (!prefetch) { | |
return <RouterLink to={to} {...rest}>{children}</RouterLink > | |
} | |
return <Link to={to} {...rest}>{children}</Link> | |
} | |
MyLink.defaultProps = { | |
prefetch: true | |
} | |
export default MyLink |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment