I have a piece of code as such :
function VideoRender() {
const pRef = React.useRef()
return incData.map((el, i) => {
return (
<div key={i}>
<video ref={pRef} autoPlay></video>
</div>
)
})
}
I want to set mediaStream to the video tag right in the map function but apparently I run into errors. What is the proper way of rendering <video> and changing the mediaStream through srcObject in React?
ref has a callback so you can do something like this.
return (
<video
autoPlay
key={index}
muted
ref={(ref) => {
if (ref) ref.srcObject = remoteStream;
}}
/>
);