question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

requireNativeComponent is not exported from 'react-native'

See original GitHub issue

I am trying to setup a simple project where I am returning a camera stream in RTC View.

I keep getting this error and I have no idea why.

Failed to compile.

./node_modules/react-native-webrtc/RTCView.js
Attempted import error: 'requireNativeComponent' is not exported from 'react-native'.

import React, {useRef, useEffect} from 'react';
import {
  RTCPeerConnection,
  RTCIceCandidate,
  RTCSessionDescription,
  RTCView,
  MediaStream,
  MediaStreamTrack,
  mediaDevices,
  registerGlobals,
} from 'react-native-webrtc';

function ViewCamera() {
  const videoStream= useRef(null);

  useEffect(() => {
    if (!videoStream) {
      return;
    }
    mediaDevices.getUserMedia({video: true}).then((stream) => {
      let video = videoStream.current;
      video.srcObject = stream;
      video.play();
      console.log(stream);
    });
  }, [videoStream]);

  return <RTCView streamURL={videoStream.current.srcObject.toUrl()} />;
}

export default ViewCamera;

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
ruddellcommented, Apr 17, 2021

I built a shim for react-native-web allowing you to use (almost) the same code in react-native-web as in react-native. It works with expo, as long as you eject.

The code itself is pretty short to read, just about 100 lines total (excluding tests). Includes a demo expo app with KITE tests ensuring it works across Chrome/Firefox/Safari.

Repo is at https://github.com/ruddell/react-native-webrtc-web-shim, any feedback is welcome.

1reaction
saghulcommented, Dec 9, 2020

The shin would be pretty simple actually, since WebRTC is a standard browser API. Checking the W3C WebRTC API and exporting the necessary parts would be a reasonable next step.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting error 'requireNativeComponent' is not exported from ...
Attempted import error : 'requireNativeComponent' is not exported from 'react-native-web/dist/index'. Describe what you expected to happen:.
Read more >
How to fix import error : 'requireNativeComponent' from 'react ...
Attempted import error : 'requireNativeComponent' is not exported from 'react-native-web/dist/index'. Please tell me why this is happening and ...
Read more >
Prerequisites for Libraries - React Native
JavaScript spec files must be named Native<MODULE_NAME>.js and they export a TurboModuleRegistry Spec object. The name convention is ...
Read more >
react-native-webview - npm
React Native WebView component for iOS, Android, macOS, and Windows. Latest version: 11.26.0, last published: 5 days ago.
Read more >
Troubleshooting | React Navigation
These issues may or may not be related to React Navigation itself. ... Error: While trying to resolve module "@react-navigation/native" from file ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found