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

22 lines
522 B
TypeScript
Raw Normal View History

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-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 />
}
if (route.options.hasHandler) {
console.log('Has rust handler')
}
2024-05-11 16:22:15 +02:00
return route.options.component()
2024-05-11 15:08:49 +02:00
})