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'
|
2024-08-14 20:50:47 +02:00
|
|
|
import useRoute from '../hooks/useRoute'
|
2024-05-11 15:08:49 +02:00
|
|
|
|
2024-05-23 20:41:05 +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)
|
|
|
|
|
|
2024-08-14 20:50:47 +02:00
|
|
|
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 />
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-23 20:41:05 +02:00
|
|
|
return <RouteMatch route={route} serverSideProps={serverSideProps} />
|
2024-05-14 21:23:32 +02:00
|
|
|
}
|