import * as React from 'react' ; import { useInterval } from 'react-use' ; import WebMidi from "webmidi" ; export const useMidiDevices = ( ) => { const [ availableDevices , setAvailableDevices ] = React . useState ( { inputs : WebMidi . inputs , outputs : WebMidi . outputs } ) ; const update = React . useCallback ( ( ) => { const inputs = WebMidi . inputs ; const outputs = WebMidi . outputs ; setAvailableDevices ( { inputs , outputs } ) ; } , [ ] ) ; useInterval ( update , 500 ) ; return availableDevices ; } ; export default useMidiDevices ;