From f2bcdf7d569e5239506dbea7f0399955297f5f8b Mon Sep 17 00:00:00 2001 From: EkaanshArora Date: Wed, 15 Sep 2021 02:14:11 +0530 Subject: [PATCH] add error to customVideoTrack --- src/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 75182a3..146ff64 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -245,6 +245,7 @@ export function createCustomVideoTrack(config: CustomVideoTrackInitConfig) { } return function useCustomVideoTrack() { const [ready, setReady] = useState(false) + const [agoraRTCError, setAgoraRTCError] = useState(null) const ref = useRef(track) useEffect(() => { @@ -252,6 +253,8 @@ export function createCustomVideoTrack(config: CustomVideoTrackInitConfig) { createClosure().then((track) => { ref.current = track setReady(true) + }, (e) => { + setAgoraRTCError(e) }) } else { setReady(true) @@ -260,7 +263,7 @@ export function createCustomVideoTrack(config: CustomVideoTrackInitConfig) { track = null } }, []) - return { ready, track: ref.current } + return { ready, track: ref.current, error: agoraRTCError } } }