Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Rejection (TypeError): myVideo.current is undefined #7

Open
wasim2725 opened this issue Oct 2, 2021 · 5 comments
Open

Unhandled Rejection (TypeError): myVideo.current is undefined #7

wasim2725 opened this issue Oct 2, 2021 · 5 comments

Comments

@wasim2725
Copy link

C:/Users/mohdw/Desktop/WebRTC/client/src/SocketContext.js:26

.then((currentStream) => {
setStream(currentStream);

        myVideo.current.srcObject = currentStream;
    });
@adarsh-chakraborty
Copy link

Did you find any solution?

@dynamo58
Copy link

Don't know if this is still relevant, but this worked for me:

With the default boilerplate generated by create-react-app I had something like this in my index client file

import ReactDOM from 'react-dom/client';
import './styles/index.css';
import App from './App';
import { ContextProvider } from './Context';

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);
root.render(
  <ContextProvider>
    <App />
  </ContextProvider>
);

I changed this to match the video and turned it into

import ReactDOM from 'react-dom';
import './styles/index.css';
import App from './App';

import { ContextProvider } from './Context';

ReactDOM.render(
  <ContextProvider>
    <App />
  </ContextProvider>,
  document.getElementById('root') as HTMLElement
);

I am absolutely oblivious as to why this fixes the issue, but it did for me.

@OkezeKingsley
Copy link

I'm currently facing as issue with this. The project isn't working because of this, I've tried multiple ways, but still haven't gotten a better solution.😤

@gihev72
Copy link

gihev72 commented Nov 9, 2022

try this, it may help🫥

`
useEffect(()=>{

const getMd = async () => {
    const currentStream = await navigator.mediaDevices.getUserMedia({video: true, audio: true});
    setStream(currentStream);
    myVideo.current.srcObject = currentStream;
}

(async ()=> await getMd())();
// getMd()

socket.on("me", (id)=> setMe(id))

socket.on("calluser", ({from, name:callerName, signal})=>{
  setCall({isReceiveCall: true, from, name: callerName, signal})
})

}, []);
`

@OkezeKingsley
Copy link

OkezeKingsley commented Nov 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants