adrianhajdin / project_video_chat

This is a code repository for the corresponding YouTube video. In this tutorial, we're going to build and deploy a React Video Chat Application using WebRTC.
850 stars 392 forks source link

TypeError: Cannot set properties of undefined (setting 'srcObject') #20

Open AbhinavNaman opened 1 year ago

AbhinavNaman commented 1 year ago

Cannot set properties of undefined (setting 'srcObject') TypeError: Cannot set properties of undefined (setting 'srcObject') at http://localhost:3000/static/js/bundle.js:181:33

shivamt2708 commented 1 year ago

okk

mohan-246 commented 1 year ago

Heyy how did you fix it?

tusharsircar95 commented 1 year ago

myVideo and userVideo references are initialized to null via useRef(). Hence, myVideo.current and currentVideo.current are null, which is why you see the above error.

The solution is to assign a value to this reference which is done here.

See more details about setting reference via the refs property here.

trane7776 commented 8 months ago

just delete the part of this {stream && () } It's because your ref doesn't create before you run a streaming video.