AppRegistry.registerComponent() not working with Expo - react-native

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

Related

Vector icons in expo snack

I want to add icons to my react native snack expo app.
I tried using this:
import MaterialIcons from '#expo/vector-icons'
And when I added the component <MaterialIcons name="delete" /> in my main functional component, it throws me an error.
I am using the online code editor called snack expo for building my app. Can someone help me how to use vector icons in the snack expo?
Many thanks for considering my request.
Import MaterialIcons like this:
import { MaterialIcons } from '#expo/vector-icons';
// then use it
<MaterialIcons name="delete" />
For more: MaterialIcons

React Native Mapview component into Expo project

I wish to add the React Native MapView Component to the new project I have created using expo. The instructions explain that I need to modify files in the iOS and Android folders, but expo doesn't generate iOS and Android folders, right?
Can I use this component in my project?
It's included as per https://docs.expo.io/versions/latest/sdk/map-view/
"No setup required for use within the Expo app, or within a standalone app for iOS."
import React from 'react';
import MapView from 'react-native-maps';
export default class App extends React.Component {
render() {
return (
<MapView style={{flex: 1}} />
);
}
}

how do I integrate Instagram auth login in expo react native app

I am new to React Native and i am trying to implement the Instagram auth login in my app. I created the project using expo cli.
I have tried 2 solutions so far-
i used the instagram api provided for authentication https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code...
this api returns me a HTML template, when i render that template inside WebView component of react native, it just shows the instagram splash screen with thumbnail icon and nothing more.
i used react-native-instagram-login npm module but that didn't work coz it's probably a native module and not supported by expo.
I have also looked upon auth0 module, but i guess it also is a native module itself.
Have you configured uri correctly with webView?
example.js
import React, { Component } from 'react';
import { WebView } from 'react-native';
class MyWeb extends Component {
render() {
return (
<WebView
source={{uri: 'https://github.com/facebook/react-native'}}
style={{marginTop: 20}}
/>
);
}
}

Implementing CodePush for ReactNative with Emulator

We are testing the code push implementation for our ReactNative application to push js updates.
Changes Done:
Created App center login and connected to the github repo.
Deployed CodePush from my react native project using cmd
appcenter codepush release-react -a chandrasekarg/ReactNativeCodePush
-d Staging
Modified app.js File as below
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import codePush from "react-native-code-push";
let codePushOptions = { checkFrequency: codePush.CheckFrequency.ON_APP_RESUME };
class App extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to Code Push Test !</Text>
</View>
);
}
}
App = codePush(codePushOptions)(App);
export default App;
Where should i have to add the details about my AppCenter account and the Project name to look for the JS bundle.?
how to test the Code Push with Android Emulator.?
You can either hard code ur deployment key in MainActivity.java or have it loaded dynamically.
Please refer to https://learn.microsoft.com/en-us/appcenter/distribution/codepush/react-native for more information

Application Project has not been registered

I am trying to run my react native app on my device .
So I am running react-native start
everything looks fine.
and when running react-native run-android I get this error
otherwise, I get this error in my device
My issue was the name I gave the project differed from the name that was being registered in AppRegistry
AppRegistry.registerComponent('proj', () => proj)
proj needs to be the same as the name of the project in the gradle and config files.
You need to export the class. Use the code below
import React, { Component } from 'react'
import { AppRegistry, Text, View } from 'react-native'
export default class proj extends Component {
render() {
return (
<View style={styles.container}> <Text > Welcome to PutainDeBiere! </Text> </View> )
}
}
AppRegistry.registerComponent('proj', () => proj)
Delete / uninstall first the APP installed and then do a clean install of it and see if it works.