addStream TypeError: undefined is not a function

Hello,
I’m new to React Native and so to React-Native-WebRTC.
Trying to create simple demo, I’m failling right at the beginning.
I get the following error when trying to invoke addStream:
TypeError: undefined is not a function

My simple source code, App.js:

import React, { useState } from ‘react’;
import type {Node} from ‘react’;
import {
Button,
View,
} from ‘react-native’;

import {
ScreenCapturePickerView,
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
RTCView,
MediaStream,
MediaStreamTrack,
mediaDevices,
registerGlobals
} from ‘react-native-webrtc’;

import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from ‘react-native/Libraries/NewAppScreen’;

let cameraCount = 0;

let peerConstraints = {
iceServers: [
{
urls: ‘stun:stun.l.google.com:19302’
}
]
};

let peerConnection = new RTCPeerConnection( peerConstraints );

const getMediaStream = async () => {
let mediaConstraints = {
audio: true,
video: {
frameRate: 30,
facingMode: ‘user’
}
};

let localMediaStream;
let isVoiceOnly = false;

try {
const mediaStream = await mediaDevices.getUserMedia( mediaConstraints );

if ( isVoiceOnly ) {
  let videoTrack = await mediaStream.getVideoTracks()[ 0 ];
  videoTrack.enabled = false;
};

localMediaStream = mediaStream;
console.log(mediaStream);
peerConnection.addStream(localMediaStream);

} catch( err ) {
// Handle Error
console.log(err);
};
}

const addMediaSteam = async () => {
}

const releaseMediaStream = async () => {
}

const App: () => Node = () => {
return (





);
};

export default App;

Thank you for your help!

Are you running a version higher than 1.106.1 of react-native-webrtc?

You basically have 2 options.
Either you’ll need to change over to the new methods of handling streams/tracks with Unified Plan or you can downgrade the package to 1.106.1 which is the last version to support Plan B.

I was using 106.0.0-beta.7. This version was installed automatically. However, I installed 1.106.1 and now the error doesn’t occur. Thank you. I will continue with the Step by Step guide.