Skip to content

Commit

Permalink
fix: Don't warn when setting prefetch={true} on <Link /> (#1463)
Browse files Browse the repository at this point in the history
Fixes #1462
  • Loading branch information
amannn authored Oct 24, 2024
1 parent af789e3 commit fd6d73d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/next-intl/.size-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ const config: SizeLimitConfig = [
name: "import {createSharedPathnamesNavigation} from 'next-intl/navigation' (react-client)",
path: 'dist/production/navigation.react-client.js',
import: '{createSharedPathnamesNavigation}',
limit: '4.04 KB'
limit: '4.045 KB'
},
{
name: "import {createLocalizedPathnamesNavigation} from 'next-intl/navigation' (react-client)",
path: 'dist/production/navigation.react-client.js',
import: '{createLocalizedPathnamesNavigation}',
limit: '4.04 KB'
limit: '4.045 KB'
},
{
name: "import {createNavigation} from 'next-intl/navigation' (react-client)",
path: 'dist/production/navigation.react-client.js',
import: '{createNavigation}',
limit: '4.045 KB'
limit: '4.055 KB'
},
{
name: "import {createSharedPathnamesNavigation} from 'next-intl/navigation' (react-server)",
path: 'dist/production/navigation.react-server.js',
import: '{createSharedPathnamesNavigation}',
limit: '16.78 KB'
limit: '16.795 KB'
},
{
name: "import {createLocalizedPathnamesNavigation} from 'next-intl/navigation' (react-server)",
Expand Down
11 changes: 11 additions & 0 deletions packages/next-intl/src/navigation/createNavigation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ describe.each([
}}
/>;
});

it('does not warn when setting the `prefetch` prop', () => {
const consoleSpy = vi.spyOn(console, 'error');
const markup = renderToString(
<Link href="/about" prefetch>
About
</Link>
);
expect(markup).toContain('href="/en/about"');
expect(consoleSpy).not.toHaveBeenCalled();
});
});

describe('getPathname', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-intl/src/navigation/shared/BaseLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function BaseLink(
ref: ComponentProps<typeof NextLink>['ref']
) {
const curLocale = useLocale();
const isChangingLocale = locale !== curLocale;
const isChangingLocale = locale != null && locale !== curLocale;
const linkLocale = locale || curLocale;
const host = useHost();

Expand Down

0 comments on commit fd6d73d

Please sign in to comment.