Skip to content

Commit

Permalink
Add tests for router.push(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyz committed May 19, 2023
1 parent 94c1b83 commit b63b856
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use client'

import { useRouter } from 'next/navigation'

export function RouterPushButton() {
const router = useRouter()

return (
<h3 id="h3">
<button
id="button-to-h3-hash-only"
onClick={() => {
router.push('#h3')
}}
>
To #h3, hash only
</button>
</h3>
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Link from 'next/link'
import { RouterPushButton } from './client-component'

export default function Page() {
return (
Expand All @@ -20,6 +21,8 @@ export default function Page() {
To #h2, with both relative hash and query
</Link>
</h2>

<RouterPushButton />
</>
)
}

0 comments on commit b63b856

Please sign in to comment.