I'm trying to write a react-native app using expo, and I started off using its starter code for an app with multiple tabs. I then created a LoginScreen.js file, shown below:
import React, { Component } from 'react';
import { AppRegistry, TextInput, Button } from 'react-native';
export default class Login extends React.Component {
constructor(props) {
super(props);
this.state = { username: '', passwd: '', };
}
render() {
return (
<React.Fragment>
<TextInput>
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(username) => this.setState({username})}
value={this.state.username}
</TextInput>
<TextInput>
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(passwd) => this.setState({passwd})}
value={this.state.passwd}
</TextInput>
<Button>
onPress={this.verifyLogin}
title = "Login"
</Button>
</React.Fragment>
);
}
verifyLogin() {
if (this.state.username == 'test' && this.state.passwd == 'test'){
this.setState( () => ({username: 'login succeeded!'}));
}
}
}
I want to use this as the first page that the user sees instead of the default HomeScreen.js. I tried to do this by adding the following line to my app.json file:
"entryPoint": "screens/LoginScreen.js"
However, when I try this I get the following error message: Module AppRegistry is not registered callable module (calling runApplication)I have already found two other stackoverflow questions regarding the same erorr message (Module AppRegistry is not registered callable module (calling runApplication) and React-Native: Module AppRegistry is not a registered callable module), and I have already tried the solutions in the first one (e.g. restarting npm, adding the line
AppRegistry.registerComponent("Login", () => Login))
which gives me the following error message: Application main has not been registered). In addition, the two stackoverflow pages that I have referenced are not using expo but are using react-native directly, meaning that some of the files they reference do not exist for me (such as the index.ios.js file). Furthermore, I have tried copying and pasting the entirety of the contents of the HomeScreen.js file into the Login.js file, and it still gave me the same error, leading me to believe that there's some other setting I need to set, but I can't figure out what. Any help in getting rid of this erorr or some other way of making the first page the Login page would be helpful.