Skip to content

Commit

Permalink
remove nextjs link prefetch
Browse files Browse the repository at this point in the history
  • Loading branch information
isstuev committed Jan 28, 2025
1 parent a0a3b38 commit 1c7a66e
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 11 deletions.
5 changes: 5 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const RESTRICTED_MODULES = {
importNames: [ 'Popover', 'Menu', 'PinInput', 'useToast', 'Skeleton' ],
message: 'Please use corresponding component or hook from ui/shared/chakra component instead',
},
{
name: 'next/link',
importNames: [ 'default' ],
message: 'Please use ui/shared/NextLink component instead',
},
],
patterns: [
'icons/*',
Expand Down
2 changes: 1 addition & 1 deletion ui/address/tokenSelect/TokenSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Box, Flex, IconButton, Tooltip } from '@chakra-ui/react';
import { useQueryClient, useIsFetching } from '@tanstack/react-query';
import { sumBy } from 'es-toolkit';
import NextLink from 'next/link';
import { useRouter } from 'next/router';
import React from 'react';

Expand All @@ -13,6 +12,7 @@ import * as mixpanel from 'lib/mixpanel/index';
import getQueryParamString from 'lib/router/getQueryParamString';
import Skeleton from 'ui/shared/chakra/Skeleton';
import IconSvg from 'ui/shared/IconSvg';
import NextLink from 'ui/shared/NextLink';

import useFetchTokens from '../utils/useFetchTokens';
import TokenSelectDesktop from './TokenSelectDesktop';
Expand Down
2 changes: 1 addition & 1 deletion ui/marketplace/Banner/FeaturedApp.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Link, useColorModeValue, LinkBox, Flex, Image, LinkOverlay, IconButton } from '@chakra-ui/react';
import NextLink from 'next/link';
import type { MouseEvent } from 'react';
import React, { useCallback } from 'react';

Expand All @@ -8,6 +7,7 @@ import type { MarketplaceAppPreview } from 'types/client/marketplace';
import useIsMobile from 'lib/hooks/useIsMobile';
import * as mixpanel from 'lib/mixpanel/index';
import Skeleton from 'ui/shared/chakra/Skeleton';
import NextLink from 'ui/shared/NextLink';

import FavoriteIcon from '../FavoriteIcon';
import MarketplaceAppIntegrationIcon from '../MarketplaceAppIntegrationIcon';
Expand Down
3 changes: 2 additions & 1 deletion ui/marketplace/MarketplaceAppCardLink.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { LinkOverlay, chakra } from '@chakra-ui/react';
import NextLink from 'next/link';
import React from 'react';
import type { MouseEvent } from 'react';

import NextLink from 'ui/shared/NextLink';

type Props = {
id: string;
url: string;
Expand Down
3 changes: 2 additions & 1 deletion ui/marketplace/MarketplaceAppModalLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Button } from '@chakra-ui/react';
import NextLink from 'next/link';
import React from 'react';

import NextLink from 'ui/shared/NextLink';

type Props = {
id: string;
url: string;
Expand Down
2 changes: 1 addition & 1 deletion ui/marketplace/MarketplaceDisclaimerModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Heading, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, ModalOverlay, Text, Button, useColorModeValue } from '@chakra-ui/react';
import NextLink from 'next/link';
import React from 'react';

import useIsMobile from 'lib/hooks/useIsMobile';
import NextLink from 'ui/shared/NextLink';

type Props = {
isOpen: boolean;
Expand Down
15 changes: 15 additions & 0 deletions ui/shared/NextLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// eslint-disable-next-line no-restricted-imports
import NextLink, { type LinkProps as NextLinkProps } from 'next/link';
import type { ReactNode } from 'react';

type LinkProps = NextLinkProps & { children?: ReactNode };

const Link = ({ prefetch = false, children, ...rest }: LinkProps) => {
return (
<NextLink prefetch={ prefetch } { ...rest }>
{ children }
</NextLink>
);
};

export default Link;
2 changes: 1 addition & 1 deletion ui/shared/chart/ChartWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Tooltip,
useColorModeValue,
} from '@chakra-ui/react';
import NextLink from 'next/link';
import React, { useRef } from 'react';

import type { TimeChartItem } from './types';
Expand All @@ -15,6 +14,7 @@ import { route, type Route } from 'nextjs-routes';
import config from 'configs/app';
import Skeleton from 'ui/shared/chakra/Skeleton';
import IconSvg from 'ui/shared/IconSvg';
import NextLink from 'ui/shared/NextLink';

import ChartMenu from './ChartMenu';
import ChartWidgetContent from './ChartWidgetContent';
Expand Down
3 changes: 2 additions & 1 deletion ui/shared/links/LinkInternal.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { LinkProps, FlexProps } from '@chakra-ui/react';
import { Flex, Link } from '@chakra-ui/react';
import type { LinkProps as NextLinkProps } from 'next/link';
import NextLink from 'next/link';
import type { LegacyRef } from 'react';
import React from 'react';

import NextLink from 'ui/shared/NextLink';

import type { Variants } from './useLinkStyles';
import { useLinkStyles } from './useLinkStyles';

Expand Down
2 changes: 1 addition & 1 deletion ui/shared/stats/StatsWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Box, Flex, Text, useColorModeValue, chakra } from '@chakra-ui/react';
import NextLink from 'next/link';
import React from 'react';

import type { Route } from 'nextjs-routes';

import Skeleton from 'ui/shared/chakra/Skeleton';
import Hint from 'ui/shared/Hint';
import IconSvg, { type IconName } from 'ui/shared/IconSvg';
import NextLink from 'ui/shared/NextLink';
import TruncatedValue from 'ui/shared/TruncatedValue';

export type Props = {
Expand Down
2 changes: 1 addition & 1 deletion ui/snippets/navigation/vertical/NavLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Link, Text, HStack, Tooltip, Box, useBreakpointValue } from '@chakra-ui/react';
import NextLink from 'next/link';
import React from 'react';

import type { NavItem } from 'types/client/navigation';
Expand All @@ -9,6 +8,7 @@ import { route } from 'nextjs-routes';
import useIsMobile from 'lib/hooks/useIsMobile';
import { isInternalItem } from 'lib/hooks/useNavItems';
import IconSvg from 'ui/shared/IconSvg';
import NextLink from 'ui/shared/NextLink';

import LightningLabel, { LIGHTNING_LABEL_CLASS_NAME } from '../LightningLabel';
import NavLinkIcon from '../NavLinkIcon';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Image, Flex, Text, useColorModeValue } from '@chakra-ui/react';
import NextLink from 'next/link';
import React from 'react';

import type { MarketplaceAppOverview } from 'types/client/marketplace';

import highlightText from 'lib/highlightText';
import IconSvg from 'ui/shared/IconSvg';
import NextLink from 'ui/shared/NextLink';

import SearchBarSuggestItemLink from './SearchBarSuggestItemLink';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { LinkProps as NextLinkProps } from 'next/link';
import NextLink from 'next/link';
import React from 'react';

import type { SearchResultItem } from 'types/client/search';
import type { AddressFormat } from 'types/views/address';

import { route } from 'nextjs-routes';

import NextLink from 'ui/shared/NextLink';

import SearchBarSuggestAddress from './SearchBarSuggestAddress';
import SearchBarSuggestBlob from './SearchBarSuggestBlob';
import SearchBarSuggestBlock from './SearchBarSuggestBlock';
Expand Down

0 comments on commit 1c7a66e

Please sign in to comment.