Hook is used for fetch specific game data.
Hook represents a logic wrapper over standard Apollo's useQuery
hook. Explore Apollo's docs (opens in a new tab) to understand what data the hooks return.
Usage
import { useGame } from '@azuro-org/data'
const { loading, error, data: game } = useGame(props)
Props
{
gameId: string | bigint
}
⚠️
gameId
property is not the same as id
. Each game fetched using useGames
hook contains the gameId:
import { useGame } from '@azuro-org/data'
const { loading, error, data } = useGames()
const gameId = data?.games[0]?.gameId
const { loading, error, data } = useGame({ gameId })
Return Value
{
loading: boolean
error: Error | null
data: {
id: string
gameId: number
title?: string | null
startsAt: number
sport: {
slug: string
name: string
}
league: {
slug: string
name: string
country: {
slug: string
name: string
}
}
participants: Array<{
image?: string | null
name: string
}>
}
}