I am trying to stream a video, but when i set 'myVideo.current.srcObject = currentStream' as in the code below, I recieve an error 'Cannot set properties of undefined (setting 'srcObject')'
const myVideo = useRef({});
const userVideo = useRef({});
const connectionRef = useRef();
useEffect(() => {
navigator.mediaDevices
.getUserMedia({ video: true, audio: true })
.then((currentStream) => {
setStream(currentStream);
myVideo.current.srcObject = currentStream;
});
socket.on("me", (id) => {
setMe(id);
});socket.on("callUser", ({ from, callerName, signal }) => {
setCall({ isReceivedCall: true, from, callerName, signal });
});
}, []);```