Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix hydration mismatch on href for url with anchor refs (#21065)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ceef156
commit cdab7bf
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
|
||
const Home = () => { | ||
return ( | ||
<> | ||
<Link href="#hash-link"> | ||
<a>Hash Link</a> | ||
</Link> | ||
</> | ||
) | ||
} | ||
|
||
export default Home |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* eslint-env jest */ | ||
|
||
import { join } from 'path' | ||
import webdriver from 'next-webdriver' | ||
import { | ||
findPort, | ||
launchApp, | ||
killApp, | ||
nextStart, | ||
nextBuild, | ||
} from 'next-test-utils' | ||
|
||
jest.setTimeout(1000 * 60 * 5) | ||
let app | ||
let appPort | ||
const appDir = join(__dirname, '..') | ||
|
||
const runTests = () => { | ||
it('should not have hydration mis-match for hash link', async () => { | ||
const browser = await webdriver(appPort, '/') | ||
const browserLogs = await browser.log('browser') | ||
let found = false | ||
browserLogs.forEach((log) => { | ||
if (log.message.includes('Warning: Prop')) { | ||
found = true | ||
} | ||
}) | ||
expect(found).toEqual(false) | ||
}) | ||
} | ||
|
||
describe('Link with hash href', () => { | ||
describe('development', () => { | ||
beforeAll(async () => { | ||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort) | ||
}) | ||
afterAll(() => killApp(app)) | ||
|
||
runTests() | ||
}) | ||
|
||
describe('production', () => { | ||
beforeAll(async () => { | ||
await nextBuild(appDir) | ||
appPort = await findPort() | ||
app = await nextStart(appDir, appPort) | ||
}) | ||
afterAll(() => killApp(app)) | ||
|
||
runTests() | ||
}) | ||
}) |
cdab7bf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stats from current release
Default Server Mode (Increase detected⚠️ )
General Overall increase⚠️
Page Load Tests Overall increase ✓
Client Bundles (main, webpack, commons) Overall increase⚠️
Legacy Client Bundles (polyfills) Overall increase⚠️
Client Pages Overall increase⚠️
Client Build Manifests Overall decrease ✓
Rendered Page Sizes Overall decrease ✓
Diffs
Diff for _buildManifest.js
Diff for _error-a0c45..8e97fa7be.js
Diff for link-3a08ad7..2582ee217.js
Diff for link-67e8576..0c009f99f.js
Diff for routerDirect..88cd3382e.js
Diff for withRouter-9..6729e701e.js
Diff for 677f882d2ed8..4eeebf399.js
Diff too large to display
Diff for main-2aa8068..281f09665.js
Diff too large to display
Diff for polyfills-f7..972ef83e9.js
Diff for index.html
Diff for link.html
Diff for withRouter.html
Serverless Mode (Increase detected⚠️ )
General Overall increase⚠️
Client Bundles (main, webpack, commons) Overall increase⚠️
Legacy Client Bundles (polyfills) Overall increase⚠️
Client Pages Overall increase⚠️
Client Build Manifests Overall decrease ✓
Serverless bundles Overall decrease ✓