-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix hydration mismatch on href for url with anchor refs #21065
Merged
timneutkens
merged 6 commits into
vercel:canary
from
kaykdm:fix/hydration-mismatch-href
Jan 15, 2021
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
90273a9
fix hydration mismatch on href for url with anchor refs
fc98fde
add test
f13e7df
read browser logs from webdriver for test
00c0906
Update test/integration/link-with-hash/test/index.test.js
kaykdm 6957e0c
Merge branch 'canary' into fix/hydration-mismatch-href
kodiakhq[bot] c2f27b8
fix lint
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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() | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hi, this warning won't show in production mode so we don't need to test that, we could add this check to the client-navigation suite here using the
/nav/hash-changes
page to keep the test related to that. The check looks good besides that!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.
@ijjk (cc: @timneutkens )
Hi, thanks for the review!
You are right that this warning does not show in production.
I was not sure where to put this test, so I created new one. Adding this check to the client-navigation suite using the
/nav/hash-changes
makes sense to me.Since this PR is merged, should I make an another PR to apply your suggestion?
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.
If you'd like to create another PR updating the test that would be awesome!