I would like to convert React class component to functional component.
const remoteVideoref = useRef(null);
this.pc.ontrack = (e) => {
this.remoteVideoref.current.srcObject = e.streams[0]
}
Is this the correct way of doing it?
const remoteVideoref = useRef(null);
this.pc.ontrack = (e) => {
remoteVideoref.current.srcObject = e.streams[0]
}
2
Answers
Assume this class component:
When you types a name in the input field and clicks the Alert button, it pops up an alert with the name defined in state.
You can convert this entire class into a functional React component using Hooks:
If this is what you mean, then I hope this helps.
function component code for your code will be as following
and your can call ontrack function anywhere like
ontrack(event)