import React from 'react' ; import { getWindow , isBrowser } from '../helpers/window' ; param { String } event param { Func } callback example function useWindowEvent < T extends keyof WindowEventMap > ( event , callback ) { if ( ! isBrowser ( ) ) { return ; } const environment = getWindow ( ) ; React . useEffect ( ( ) => { environment . addEventListener ( event , callback ) ; return ( ) => environment . removeEventListener ( event , callback ) ; } , [ event , callback ] ) ; } export default useWindowEvent ;