import { useEffect , useState } from "react" ; export const useVideoInputList = ( ) => { const [ videoInputList , setVideoInputList ] = useState < { [ id ] : string ; } > ( { } ) ; useEffect ( ( ) => { const videoInputDevices = { } ; navigator . mediaDevices . enumerateDevices ( ) . then ( list => { list . filter ( ( x ) => { return x . kind === "videoinput" ; } ) . forEach ( x => { videoInputDevices [ x . label ] = x . deviceId ; } ) ; setVideoInputList ( videoInputDevices ) ; } ) ; } , [ ] ) ; return { videoInputList } ; } ;