Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
add error to customVideoTrack
Browse files Browse the repository at this point in the history
  • Loading branch information
EkaanshArora committed Sep 14, 2021
1 parent 5ee50af commit f2bcdf7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,16 @@ export function createCustomVideoTrack(config: CustomVideoTrackInitConfig) {
}
return function useCustomVideoTrack() {
const [ready, setReady] = useState(false)
const [agoraRTCError, setAgoraRTCError] = useState<null | AgoraRTCError>(null)
const ref = useRef(track)

useEffect(() => {
if (ref.current === null) {
createClosure().then((track) => {
ref.current = track
setReady(true)
}, (e) => {
setAgoraRTCError(e)
})
} else {
setReady(true)
Expand All @@ -260,7 +263,7 @@ export function createCustomVideoTrack(config: CustomVideoTrackInitConfig) {
track = null
}
}, [])
return { ready, track: ref.current }
return { ready, track: ref.current, error: agoraRTCError }
}
}

Expand Down

0 comments on commit f2bcdf7

Please sign in to comment.