我是React本机和实现React导航的新手,但是即使我导出了我的组件,获取用于路由的组件也必须是React组件 我已经检查了所有相关答案,但都没有用。
import {AppRegistry} from 'react-native';
import {name as appName} from './app.json';
import Launch from './Launch';
AppRegistry.registerComponent(appName, () => Launch);
下面是发射
import React from 'react';
import AppNavigator from './AppNavigator'
export default class Launch extends React.Component {
render() {
return (
<AppNavigator></AppNavigator>
);
}
}
App Navigator
//..........................
import React, { Component } from 'react';
import LoginScreen from './components/src/Login/LoginScreen'
import App from './components/src/App';
import Register from './components/src/Signup/Register';
import ViewPagerPage from './components/src/Settings/CPU/ViewPagerPage'
import TabIndicatorPage from './components/pages/TabIndicatorPage'
import TitleIndicatorPage from './components/pages/TitleIndicatorPage'
import {
createStackNavigator,
createAppContainer
} from 'react-navigation';
const RootStack = createStackNavigator({
LoginScreen: { screen: LoginScreen },
TabIndicatorPage: { screen: TabIndicatorPage },
TitleIndicatorPage: {
screen: TitleIndicatorPage, navigationOptions: {
header: null
}
},
ViewPagerPage: { screen: ViewPagerPage },
Register: {
screen: Register, navigationOptions: {
header: null
}
},
App: {
screen: App,
navigationOptions: {
header: null
}
},
ViewPagerPage: { screen: ViewPagerPage },
// Detail:{screen:Detail},
// SecondScreen:{screen:SecondScreen},
});
const AppNavigator = createAppContainer(RootStack);
export default AppNavigator;
这是Login Controller给出错误,我也使用了导出。
import React, {Component} from 'react';
import {View,ScrollView,KeyboardAvoidingView,Animated,ImageBackground,
TouchableOpacity,TextInput, KeyboardAwareScrollView,StyleSheet,Image,Easing,Text,AsyncStorage,ToastAndroid} from 'react-native';
import App from '../App';
import bgSrc from './images/wallpaper.png';
import logoImg from './images/logo.png';
import { NavigationActions,StackActions } from 'react-navigation'
import usernameImg from './images/username.png';
import passwordImg from './images/password.png';
import spinner from './images/loading.gif';
const MARGIN = 40;
import Dimensions from 'Dimensions';
//登录控制器
export default class LoginScreen extends React.Component<{}> {
constructor(props) {
super(props);
this.state = { Login: false,showPass: true,
press: false,
isLoading: false,
navigator:this.props.navigator,
email:'',
应该出现预期的登录屏幕
但是我正在红屏显示组件必须反应