0

Need to set Login page as my rootview and used code. if i use the login page details in app.js file getting the result but tried to import login.js in app.js file its not working

import React, {Component} from 'react';
import { StyleSheet, 
  NavigatorIOS,} from 'react-native';

import LoginPage from './src/pages/Login'; 



type Props = {};
export default class App extends Component<{}> {

  render() {
    return (
      <NavigatorIOS
        // style={styles.container}
        initialRoute={{
          title: 'Login',
          component: LoginPage,
        }}/>
    );
  }
}

and in my login.js class

import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View } from 'react-native';

export default class Login extends Component {
  render() {
    return (
      <View>
        <Text style={styles.red}>Login</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  bigblue: {
    color: 'blue',
    fontWeight: 'bold',
    fontSize: 30,
  },
  red: {
    color: 'red',
  },
});

// skip this line if using Create React Native App
AppRegistry.registerComponent('Demo', () => Login);

but it not showing the login page as rootview

1
  • could you show your index.js file the AppRegistry is normally set in the index.js file Commented Oct 24, 2018 at 5:19

1 Answer 1

1

I have an excepted answer in the below question.

How to navigate from splash screen to login screen in react native?

There is a google drive link on it from where you can download a sample project, its a simple app figure it out from the sample app how you should set up the App.js.

I suggest You should use StackNavigator for navigation its the best method to follow in my app App.js is configured using StackNavigator.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.