mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-25 12:52:47 -07:00
75c790dd6e
* refactor: create standalone router package * fix: add jsdom to tuono-router package * fix: remove test in tuono vite.config * update turbo to latest * fix: wait build before lint * fix: router types
22 lines
521 B
TypeScript
22 lines
521 B
TypeScript
import * as React from 'react'
|
|
import { useRouter } from '../hooks/useRouter'
|
|
import type { AnchorHTMLAttributes, MouseEvent } from 'react'
|
|
|
|
export default function Link(
|
|
props: AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
): JSX.Element {
|
|
const router = useRouter()
|
|
|
|
const handleTransition = (e: MouseEvent<HTMLAnchorElement>): void => {
|
|
e.preventDefault()
|
|
props.onClick?.(e)
|
|
router.push(props.href || '')
|
|
}
|
|
|
|
return (
|
|
<a {...props} onClick={handleTransition}>
|
|
{props.children}
|
|
</a>
|
|
)
|
|
}
|