如何在React Native中根据条件进行输入

时间:2019-05-09 10:23:28

标签: react-native

import React, {Component} from 'react';
import {Platform,StyleSheet,Text,View,TouchableOpacity,Alert,Image,Button} from 'react-native';
import { Dialog } from 'react-native-simple-dialogs';
import AsyncStorage from '@react-native-community/async-storage';
import {KeyboardAvoidingView} from 'react-native';

import MapView from 'react-native-maps';

import { Marker } from 'react-native-maps';
import Parse from "parse/react-native";
import {BoxShadow} from 'react-native-shadow'
import DropdownAlert from 'react-native-dropdownalert';
import HOme from './components/Home';
import EDit from './components/Editprofile';
import OFferrides from './components/OfferRides';
import PAymentmethod from './components/PaymentMethod';
import { createDrawerNavigator, createAppContainer } from "react-navigation";

import Geolocation from 'react-native-geolocation-service';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
const homePlace = { description: 'Home', geometry: { location: { lat: 48.8152937, lng: 2.4597668 } }};
const workPlace = { description: 'Work', geometry: { location: { lat: 48.8496818, lng: 2.2940881 } }};



getData = async () => {
  try {
    const value = await AsyncStorage.getItem('nameKey')
    if(value !== null) {


      const MyDrawerNavigator = createDrawerNavigator({
        Home: {
          screen: HOme,
        },
        Editprofile: {
          screen: EDit,
        },
        Offerrides: {
          screen: OFferrides,
        },
        Paymentmethod: {
          screen: PAymentmethod,
        },
      });

      const MyApp = createAppContainer(MyDrawerNavigator);
      export default MyApp;

   }else {
     const AppNavigator = createStackNavigator({
      entry: SIgnup

     });
        export default createAppContainer(AppNavigator);
   }
  } catch(e) {
   this.dropdown.alertWithType('error', 'Error', 'Error reading values');
  }
}

getData();

我正在尝试根据从异步获取的结果进行输入,并像这样进行编码,当我执行此代码时,我抛出一个错误“导出和导入应仅位于顶层“,我不想理解是什么原因造成的,但我需要此过程的替代解决方案,我将向您分享错误屏幕截图error screenshot

0 个答案:

没有答案