mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Moves the client-navigation test suite to be isolated as part of test/development. Tried to make the minimal amount of changes neccesary to ensure the tests pass first before using the newer `NextInstance` methods. <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # -->
129 lines
3.4 KiB
JavaScript
129 lines
3.4 KiB
JavaScript
import Link from 'next/link'
|
|
import { Component } from 'react'
|
|
import Router from 'next/router'
|
|
|
|
let counter = 0
|
|
|
|
const linkStyle = {
|
|
marginRight: 10,
|
|
}
|
|
|
|
export default class extends Component {
|
|
increase() {
|
|
counter++
|
|
this.forceUpdate()
|
|
}
|
|
|
|
visitQueryStringPage() {
|
|
const href = { pathname: '/nav/querystring', query: { id: 10 } }
|
|
const as = { pathname: '/nav/querystring/10', hash: '10' }
|
|
Router.push(href, as)
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className="nav-home">
|
|
<Link href="/nav/about" id="about-link" style={linkStyle}>
|
|
About
|
|
</Link>
|
|
<Link
|
|
href="/empty-get-initial-props"
|
|
id="empty-props"
|
|
style={linkStyle}
|
|
>
|
|
Empty Props
|
|
</Link>
|
|
<Link href="/nav/self-reload" id="self-reload-link" style={linkStyle}>
|
|
Self Reload
|
|
</Link>
|
|
<Link
|
|
href="/nav/shallow-routing"
|
|
id="shallow-routing-link"
|
|
style={linkStyle}
|
|
>
|
|
Shallow Routing
|
|
</Link>
|
|
<Link href="/nav/redirect" id="redirect-link" style={linkStyle}>
|
|
Redirect
|
|
</Link>
|
|
<Link
|
|
href={{ pathname: '/nav/querystring', query: { id: 10 } }}
|
|
as={{ pathname: '/nav/querystring/10', hash: '10' }}
|
|
id="query-string-link"
|
|
style={linkStyle}
|
|
>
|
|
QueryString
|
|
</Link>
|
|
<Link
|
|
href="/nav/about"
|
|
replace
|
|
id="about-replace-link"
|
|
style={linkStyle}
|
|
>
|
|
Replace state
|
|
</Link>
|
|
<Link
|
|
href="/nav/as-path"
|
|
as="/as/path"
|
|
id="as-path-link"
|
|
style={linkStyle}
|
|
>
|
|
As Path
|
|
</Link>
|
|
<Link href="/nav/as-path" id="as-path-link-no-as" style={linkStyle}>
|
|
As Path (No as)
|
|
</Link>
|
|
<Link
|
|
href="/nav/as-path-using-router"
|
|
id="as-path-using-router-link"
|
|
style={linkStyle}
|
|
>
|
|
As Path (Using Router)
|
|
</Link>
|
|
<Link href="/nav/on-click?count=1" id="on-click-link" style={linkStyle}>
|
|
An element with onClick
|
|
</Link>
|
|
<Link href="/nav/about" id="target-link" target="_blank">
|
|
An element with target
|
|
</Link>
|
|
|
|
<svg
|
|
width={24}
|
|
height={24}
|
|
fill="none"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<Link href="/nav/about" id="in-svg-link" style={{ display: 'block' }}>
|
|
<path
|
|
fillRule="evenodd"
|
|
clipRule="evenodd"
|
|
d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0Zm4.5 18a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z"
|
|
fill="#335BF1"
|
|
/>
|
|
</Link>
|
|
</svg>
|
|
|
|
<button
|
|
onClick={() => this.visitQueryStringPage()}
|
|
style={linkStyle}
|
|
id="query-string-button"
|
|
>
|
|
Visit QueryString Page
|
|
</button>
|
|
|
|
<p>This is the home.</p>
|
|
<div id="counter">Counter: {counter}</div>
|
|
<button id="increase" onClick={() => this.increase()}>
|
|
Increase
|
|
</button>
|
|
<Link href="/nav/hash-changes#item-400" id="scroll-to-hash">
|
|
Scroll to hash
|
|
</Link>
|
|
<Link href="/nav/hash-changes#中文" id="scroll-to-cjk-hash">
|
|
Scroll to CJK hash
|
|
</Link>
|
|
</div>
|
|
)
|
|
}
|
|
}
|