router changes

This commit is contained in:
2026-03-03 11:38:54 -06:00
parent 0713ad7521
commit bf1f26d851
6 changed files with 104 additions and 8 deletions

18
src/router/Link.tsx Normal file
View File

@@ -0,0 +1,18 @@
import React, {PropsWithChildren} from "react";
import {useRouter} from "./RouterContext";
export function Link(props: {className: string, href: string, replace?: boolean } & PropsWithChildren) {
const {children, className, href, replace} = props;
const router = useRouter();
function onClick(event: React.MouseEvent) {
event.preventDefault();
if(replace) {
router.replacePage(props.href);
} else {
router.pushPage(props.href);
}
}
return <a onClick={onClick} href={href} className={className}>{children}</a>
}