requireNativeComponent is not exported from 'react-native'
See original GitHub issueI 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:
- Created 3 years ago
- Comments:16 (11 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I built a shim for
react-native-web
allowing you to use (almost) the same code inreact-native-web
as inreact-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.
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.