react-native-tvos
Version:
A framework for building native apps using React
24 lines (18 loc) • 570 B
JavaScript
/*
* @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;