UNPKG

react-native-tvos

Version:
24 lines (18 loc) 570 B
/* * @flow */ import type {TVRemoteEvent} from '../../Types/CoreEventTypes'; import {type EventSubscription} from '../../vendor/emitter/EventEmitter'; import TVEventHandler from './TVEventHandler'; import * as React from 'react'; const useTVEventHandler = (handleEvent: (evt: TVRemoteEvent) => void) => { React.useEffect(() => { const subscription: EventSubscription = TVEventHandler.addListener(function(evt) { handleEvent(evt); }); return () => { subscription.remove(); }; }, [handleEvent]); }; export default useTVEventHandler;