外部导航渲染功能

时间:2019-05-03 13:16:45

标签: react-native

我具有通过检入异步存储来导航到其他组件的功能。

这是我的加载页面代码:

import React from 'react';
import { 
    View,
    Text
} from 'react-native';
import { AsyncStorage } from 'react-native';

export class LoadingScreen extends React.Component{

    componentDidMount(){
            async()=>{
                try{
                    const usertoken = await AsyncStorage.getItem('token');
                    if(usertoken !== null ){
                        return this.props.navigation.navigate('Login');
                    }else{
                        return this.props.navigation.navigate('Register');    
                    }
                }catch(error){
                    this.props.navigation.navigate('Register')
                }
        };
    }

    render(){
        return (
            <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
                <Text>This is loading...</Text>
            </View>
        );
    }
}

但是在运行应用程序时,它无法导航到另一个屏幕。 我在做什么错了?

这是我的注册组件:

import React , { Component } from 'react';
import {
    View,
    Text
} from 'react-native';
import { withNavigation } from 'react-navigation';

class RegisterScreen extends Component {

    render() {
      return (
        <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
          <Text>Register Screen</Text>
        </View>
      );
    }
}

export default withNavigation(RegisterScreen);

1 个答案:

答案 0 :(得分:0)

使用id2 <- c("Adam", "John", "Kim") obj.21 <- c(2,0,0) obj.22 <- c(1,0,0) obj.23 <- c(1,0,0) obj.24 <- c(1,0,0) obj.25 <- c(1,1,0) obj.27 <- c(0,1,0) obj.28 <- c(0,1,1) output <- data.frame(id2, obj.21, obj.22,obj.23,obj.24,obj.25,obj.27,obj.28) output 导出LoginRegister。如下所示。

withNavigation
相关问题