2024-05-11 15:08:49 +02:00
|
|
|
import * as React from 'react'
|
|
|
|
|
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-11 16:22:15 +02:00
|
|
|
export const Matches = React.memo(function () {
|
2024-05-11 15:08:49 +02:00
|
|
|
const location = useRouterStore((st) => st.location)
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
2024-05-11 16:22:15 +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-11 15:08:49 +02:00
|
|
|
})
|