2024-05-11 15:08:49 +02:00
|
|
|
import * as React from 'react'
|
|
|
|
|
import { useRouter } from '../hooks/useRouter'
|
|
|
|
|
import { useRouterStore } from '../hooks/useRouterStore'
|
|
|
|
|
|
|
|
|
|
export function Matches(): JSX.Element | undefined {
|
|
|
|
|
const matchId = useRouterStore.getState().matches[0]?.id
|
|
|
|
|
|
|
|
|
|
//if (!matchId) return <></>
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<React.Suspense>
|
|
|
|
|
<Match id={matchId} />
|
|
|
|
|
</React.Suspense>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface MatchProps {
|
|
|
|
|
id: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Match = React.memo(function ({ id }: MatchProps) {
|
|
|
|
|
const location = useRouterStore((st) => st.location)
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
|
|
console.log(router, location)
|
|
|
|
|
|
|
|
|
|
const route = router.routesById[location?.pathname]
|
|
|
|
|
|
2024-05-11 15:55:26 +02:00
|
|
|
if (route.options.hasHandler) {
|
|
|
|
|
console.log('Has rust handler')
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-11 15:08:49 +02:00
|
|
|
return route.component()
|
|
|
|
|
})
|