mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-29 22:02:46 -07:00
feat: create basic router
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import * as React from 'react'
|
||||
import { useRouter } from '../hooks/useRouter'
|
||||
import { useRouterStore } from '../hooks/useRouterStore'
|
||||
|
||||
export function Matches(): JSX.Element | undefined {
|
||||
const matchId = useRouterStore.getState().matches[0]?.id
|
||||
|
||||
//if (!matchId) return <></>
|
||||
|
||||
return (
|
||||
<React.Suspense>
|
||||
<Match id={matchId} />
|
||||
</React.Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
interface MatchProps {
|
||||
id: string
|
||||
}
|
||||
|
||||
const Match = React.memo(function ({ id }: MatchProps) {
|
||||
const location = useRouterStore((st) => st.location)
|
||||
const router = useRouter()
|
||||
|
||||
console.log(router, location)
|
||||
|
||||
const route = router.routesById[location?.pathname]
|
||||
|
||||
return route.component()
|
||||
})
|
||||
Reference in New Issue
Block a user