How to Display Video with React native - react-native

Im trying to display video on react native application, but when I run the application I have the error TypeError: undefined is not an object (evaluating 'RCTVideoInstance.Constants')
I ran these commands but it doesnot work :
npm install react-native-video
react-native link react-native-video
And this is my code :
import React from "react";
import {View} from 'react-native';
import CustomBackground from '../Components/CustomBackground';
import Video from 'react-native-video';
import videooo from '../Images/videooo.mp4'
export default class WelcomeScreen extends React.Component{
render(){
return(
<CustomBackground>
<View style={styles.btnWelcome}>
<Video source={videooo} style={styles.images} onBuffer={this.onBuffer} onEnd={this.onEnd} onError={this.videoError}/>
</View>
</CustomBackground>
)
}
}

try to use expo-av instead of react-native-video
more information : https://github.com/react-native-video/react-native-video/issues/1738#issuecomment-575243702

Related

React Native Expo issue

*** getting white screen while ***
I install React Native with Expo.
When I start the app its work normally.
After I play for a while with NativeBase UI, it gave me this white screen. Any help.
import { StatusBar } from "expo-status-bar";
import React from "react";
import Index from "./src/Home";
import { NativeBaseProvider, Box } from "native-base";
export default function App() {
return (
<NativeBaseProvider>
<Index />
</NativeBaseProvider>
);
}
Here is the white screen
here is the code

react-native-webview dose not render URL

I have seen this issue posted on stack overflow many times with no clear answer. I'm hoping this question can help me and others out.
I wish to render a URL in react native using react-native-webview
I started a blank react native project using expo init my-app. I ran npm i react-native-webview and react-native link react-native-webview. I then created a file defined as the following
import React, { Component } from 'react';
import { WebView } from 'react-native-webview';
class WebViewTest extends Component {
render() {
return (
<WebView
source={{ uri: 'https://www.google.com/' }}
style={{ marginTop: 20, width: 400, height: 400 }}
/>
);
}
}
export default WebViewTest;
My app.js imports and renders that file like the following
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import WebViewTest from './Components/WebViewTest';
export default function App() {
return (
<WebViewTest />
);
}
I test this code by running expo start and I open up my project in a web browser.
I then see the following in the browser
I don't get any errors or warnings so where am I going wrong?
As Per The Expo Docs For WebView -
https://docs.expo.io/versions/latest/sdk/webview/
https://www.npmjs.com/package/react-native-webview
It Doesn't Work On Web Using EXPO

Is there any example of using StrictMode with React-Native?

As I know about it, This checks and gives warnings for React-Native code and its lifecycles.
I read about it from What is StrictMode in react?
How can I use it in react native ?
Here is a simple example to use StrictMode in React Native
StrictMode can be directly imported from React and can used like wrapping up View inside it.
import React, {Component, StrictMode} from 'react';
import {View} from 'react-native';
class Example extends Component {
render() {
return (
<StrictMode>
<View />
</StrictMode>
);
}
}
export default Example;

AppRegistry.registerComponent() not working with Expo

I use to set the main file of my project using AppRegistry.registerComponent(), but projects created with Expo does not support it.
import { AppRegistry } from 'react-native';
import App from './src/App';
AppRegistry.registerComponent('my App', () => App);
Then, I use src/App.js as my main file. How can I do it using Expo?
Thanks
Straight from React Native docs facebook.github.io/react-native/docs/appregistry
AppRegistry is the JS entry point to running all React Native apps. App root components should register themselves with AppRegistry.registerComponent, then the native system can load the bundle for the app and then actually run the app when it's ready by invoking AppRegistry.runApplication.
In other words, since Expo isn't a complete real app because it's running on your device Expo app, doesn't have many methods available for you from react-native. Read Expo's docs for more information.
You only need on your App.js:
import React from 'react';
import { View, Text } from 'react-native';
export default () => (
<View>
<Text>Some Text</Text>
</View>
);
Check out this snack: #abranhe/stackoverflow-56694295

Save QRcode Value and Show it in another page in React Native

I wonder how I can save the value from qrcode scanner used in React Native and show the value to another page automatically. Thus, once the qrcode has been scanned, it will be redirected automatically to another page.
Is it possible to use React Navigation?
You can use react-native-qrcode-scanner the library to create this type of functionality.
react-native-camera is a dependency for this package that you'll need to add to your project. To install, run the following commands:
npm install react-native-camera --save
react-native link react-native-camera
After that install and link react-native-qrcode-scanner by the following commands:
npm install react-native-qrcode-scanner --save
react-native link react-native-qrcode-scanner
react-native link react-native-permissions
Here is a sample code for QR scanner
import React, {Component} from 'react';
import {StyleSheet, Text, View, AppRegistry, TouchableOpacity, Linking} from 'react-native';
import QRCodeScanner from 'react-native-qrcode-scanner';
export default class App extends Component {
onSuccess(e) {
//here you can do whatever you want to do on a successful scan
alert(e.data);
}
render() {
return (
<View style={{flex:1, justifyContent: 'center',}}>
<QRCodeScanner
showMarker={true}
onRead={this.onSuccess.bind(this)}
/>
</View>
);
}
}
If have face any difficulty in installation you can visit this link: https://www.npmjs.com/package/react-native-qrcode-scanner