UNPKG

react-native-tvos

Version:

A framework for building native apps using React

19 lines (16 loc) 498 B
// @flow import React from 'react'; import TVEventHandler from './TVEventHandler'; import type {TVRemoteEvent} from '../../Types/CoreEventTypes'; const useTVEventHandler = (handleEvent: (evt: TVRemoteEvent) => void) => { React.useEffect(() => { const handler: TVEventHandler = new TVEventHandler(); handler.enable(null, function(cmp, evt) { handleEvent(evt); }); return () => { handler.disable(); }; }, [handleEvent]); }; module.exports = useTVEventHandler;