11 lines
385 B
TypeScript
11 lines
385 B
TypeScript
import { createContext, useContext } from "react";
|
|
import type { Game } from "./game";
|
|
|
|
/** The game on this device, for the few screens that need more than commands (debug info). */
|
|
export const GameContext = createContext<Game | null>(null);
|
|
|
|
/** The game, or null outside `GameRoot` (component tests). */
|
|
export function useGame(): Game | null {
|
|
return useContext(GameContext);
|
|
}
|