Expo React Native中的AppLoading显示为空白

时间:2019-09-03 21:47:58

标签: android ios react-native mobile expo

我的AppLoading只是为iOS和Android显示空白页面。显示的底部选项卡告诉我模拟器已正确加载。

import React, { useState, useEffect } from 'react'
import { 
    View, 
    StyleSheet, 
    ActivityIndicator,
    Platform,
    AsyncStorage 
} from 'react-native'
import { AppLoading } from 'expo'
import { FB_TOKEN  } from "../constants";

import Slides from '../components/Slides'

const SLIDE_DATA = [
    { text: 'Welcome to JobApp', color: '#03A9F4'},
    { text: 'Use this to get a job', color: '#009688'},
    { text: 'Set your location, then swipe away', color: '#03A9F4'}
]

const WelcomeScreen = ({ navigation }) => {
    const [ token, setToken ] = useState(null)
    const getToken = async () => {
        setToken(await AsyncStorage.getItem(FB_TOKEN))         
    }
    useEffect(() => {
        getToken()     

        if (token) {
            navigation.navigate('Map')
        } else {
            setToken(false)
        }
    }, [])

    const onSlideComplete = () => {
        navigation.navigate('Auth')
    }

    if ((token === null) && Platform.OS === 'ios') {
        return <AppLoading />
    } else  if((token === null) && Platform.OS === 'android') {
        return  <ActivityIndicator
            size='large'
            />           
    }

    return (
        <View>
            <Slides 
                data={SLIDE_DATA}  
                onComplete={onSlideComplete}
            />
        </View>
    )
}

const styles = StyleSheet.create({})

export default WelcomeScreen

我尝试消除所有多余的代码,只是尝试调用AppLoading,但仍然得到相同的结果

import React from 'react'
import { AppLoading } from 'expo'


const WelcomeScreen = () => {
    return <AppLoading />
}

export default WelcomeScreen

以下是我的package.json:

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "^34.0.1",
    "expo-facebook": "~6.0.0",
    "react": "16.8.3",
    "react-dom": "^16.8.6",
    "react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
    "react-native-elements": "^1.1.0",
    "react-native-gesture-handler": "~1.3.0",
    "react-native-reanimated": "~1.1.0",
    "react-native-screens": "1.0.0-alpha.22",
    "react-native-web": "^0.11.4",
    "react-navigation": "^4.0.0",
    "react-navigation-stack": "^1.5.1",
    "react-navigation-tabs": "^2.3.0"
  },
  "devDependencies": {
    "babel-preset-expo": "^6.0.0"
  },
  "private": true
}

0 个答案:

没有答案