mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-29 22:02:46 -07:00
feat: enable server side route matching
This commit is contained in:
@@ -4,15 +4,19 @@ import { useRouterStore } from '../hooks/useRouterStore'
|
||||
import { RouteMatch } from './RouteMatch'
|
||||
import NotFound from './NotFound'
|
||||
|
||||
export const Matches = React.memo(function () {
|
||||
interface MatchesProps {
|
||||
serverPath?: string
|
||||
}
|
||||
|
||||
export function Matches({ serverPath }: MatchesProps): JSX.Element {
|
||||
const location = useRouterStore((st) => st.location)
|
||||
const router = useRouter()
|
||||
|
||||
const route = router.routesById[location?.pathname || '']
|
||||
const route = router.routesById[location?.pathname || serverPath || '']
|
||||
|
||||
if (!route) {
|
||||
return <NotFound />
|
||||
}
|
||||
|
||||
return <RouteMatch route={route} />
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user