feat: enable server side route matching

This commit is contained in:
Valerio Ageno
2024-05-14 21:23:32 +02:00
parent 1ef1a852fc
commit da75dc4a07
4 changed files with 26 additions and 8 deletions
@@ -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} />
})
}