简体   繁体   English

如何在App.js类中设置rootview反应本机

[英]How to set rootview in App.js class react native

Need to set Login page as my rootview and used code. 需要将登录页面设置为我的rootview和使用的代码。 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 如果我在app.js文件中使用登录页面详细信息获取结果,但尝试在app.js文件中导入login.js,则无法正常工作

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 在我的login.js类中

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 但它不会将登录页面显示为rootview

I have an excepted answer in the below question . 对以下问题有一个例外的回答

How to navigate from splash screen to login screen in react native? 如何在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 . 上面有一个google drive链接 ,您可以从中下载一个示例项目 ,它是一个简单的应用程序,可以从示例应用程序中了解如何设置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 . 我建议您应该使用StackNavigator进行导航, 这是在我的应用程序中遵循 最佳方法 App.js是使用StackNavigator配置的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM