# addStream TypeError: undefined is not a function

**URL:** <https://react-native-webrtc.discourse.group/t/addstream-typeerror-undefined-is-not-a-function/1672>\
**Category:** General040642add70aa006ef56b5af5b5acae3\
**Created:** [December 1, 2022, 2:00pm UTC](https://react-native-webrtc.discourse.group/t/addstream-typeerror-undefined-is-not-a-function/1672 "2022-12-01T14:00:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![user2](https://avatars.discourse-cdn.com/v4/letter/u/ecb155/32.png) [@user2](https://react-native-webrtc.discourse.group/u/user2)\
**Post date:** [December 1, 2022, 2:00pm UTC](https://react-native-webrtc.discourse.group/t/addstream-typeerror-undefined-is-not-a-function/1672/1 "2022-12-01T14:00:16Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![8BallBomBom](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/8ballbombom/32/710_2.png) [@8BallBomBom](https://react-native-webrtc.discourse.group/u/8BallBomBom)\
**Post date:** [December 2, 2022, 9:31am UTC](https://react-native-webrtc.discourse.group/t/addstream-typeerror-undefined-is-not-a-function/1672/2 "2022-12-02T09:31:23Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![user2](https://avatars.discourse-cdn.com/v4/letter/u/ecb155/32.png) [@user2](https://react-native-webrtc.discourse.group/u/user2)\
**Post date:** [December 2, 2022, 12:27pm UTC](https://react-native-webrtc.discourse.group/t/addstream-typeerror-undefined-is-not-a-function/1672/3 "2022-12-02T12:27:33Z")

</div>

I was using [106.0.0-beta.7](https://github.com/react-native-webrtc/react-native-webrtc/releases/tag/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.
