import { useGame } from './useGame' ; import { useEffect } from 'react' ; export function useGameEvent ( event , onEvent ) { const game = useGame ( ) ; useEffect ( ( ) => { game . events . on ( event , onEvent ) ; return ( ) => { game . events . off ( event , onEvent ) ; } ; } , [ onEvent ] ) ; }