Files
tuono/packages/router/src/components/Matches.tsx
T

23 lines
575 B
TypeScript
Raw Normal View History

2024-06-16 11:23:02 +02:00
import * as React from 'react'
2024-05-11 15:08:49 +02:00
import { useRouterStore } from '../hooks/useRouterStore'
2024-05-12 17:13:41 +02:00
import { RouteMatch } from './RouteMatch'
2024-05-11 16:08:51 +02:00
import NotFound from './NotFound'
import useRoute from '../hooks/useRoute'
2024-05-11 15:08:49 +02:00
interface MatchesProps {
// user defined props
serverSideProps: any
}
export function Matches({ serverSideProps }: MatchesProps): JSX.Element {
2024-05-11 15:08:49 +02:00
const location = useRouterStore((st) => st.location)
const route = useRoute(location.pathname)
2024-05-11 15:08:49 +02:00
2024-05-11 16:08:51 +02:00
if (!route) {
return <NotFound />
}
return <RouteMatch route={route} serverSideProps={serverSideProps} />
2024-05-14 21:23:32 +02:00
}