2024-05-11 15:08:49 +02:00
|
|
|
import { useRouter } from '../hooks/useRouter'
|
|
|
|
|
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-05-11 15:08:49 +02:00
|
|
|
|
2024-05-15 20:42:16 +02:00
|
|
|
export function Matches(): JSX.Element {
|
2024-05-11 15:08:49 +02:00
|
|
|
const location = useRouterStore((st) => st.location)
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
2024-05-15 20:42:16 +02:00
|
|
|
const route = router.routesById[location.pathname]
|
2024-05-11 15:08:49 +02:00
|
|
|
|
2024-05-11 16:08:51 +02:00
|
|
|
if (!route) {
|
|
|
|
|
return <NotFound />
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-12 17:13:41 +02:00
|
|
|
return <RouteMatch route={route} />
|
2024-05-14 21:23:32 +02:00
|
|
|
}
|