(已解决)TypeError:未定义不是对象(正在评估“ y.Font.isLoaded”)

时间:2019-10-14 12:52:20

标签: react-native expo mobile-application

我正在处理handlebarlabs的Currency Converter应用程序课程。我正在尝试通过从@ expo / vector-icons导入爱奥尼亚斯将图标添加到ScrollView ListItem中。

有人可以指导我我做错了什么吗?

根据课程注释,以下是我的代码:

import React, { Component } from 'react';
import { ScrollView, StatusBar, Platform } from 'react-native';
import { Ionicons } from '@expo/vector-icons';

import { ListItem, Separator } from '../components/List';

const ICON_PREFIX = Platform.OS === 'ios' ? 'ios' : 'md';
const ICON_COLOR = '#868686';
const ICON_SIZE = 23;

class Options extends Component {
    handleThemesPress = () => {
        console.log('Press Themes');
    }

    handleSitePress = () => {
        console.log('Site Press');
    }

    render() {
        return (
            <ScrollView>
                <StatusBar translucent={false} barStyle={"default"} />
                <ListItem 
                    text="Themes"
                    onPress={this.handleThemesPress}
                    customIcon={
                        <Ionicons name={`${ICON_PREFIX}-arrow-forward`} size={ICON_SIZE} color={ICON_COLOR} />
                    }
                />
                <Separator/>
                <ListItem 
                    text="Fixer.io"
                    onPress={this.handleSitePress}
                    customIcon={
                        <Ionicons name={`${ICON_PREFIX}-link`} size={ICON_SIZE} color={ICON_COLOR} />
                    }
                />

                <Separator/>
            </ScrollView>
        );
    }
}

export default Options;

以下是我得到的错误:

TypeError: undefined is not an object (evaluating 'y.Font.isLoaded')
This error is located at:
   in p
   in RCTView
   in RCTView
   in TouchableHighlight
   in f
   in RCTScrollContentView
   in RCTScrollView
   in u
   in l
   in Unknown
   in v
   in RCTView
   in RCTView
   in c

更新: 按照@Oleg的回答,我已经在SDK 35.0.0上,但是似乎以某种方式无法正确完成以前的更新。重新安装最新的SDK可解决此问题。谢谢!

1 个答案:

答案 0 :(得分:0)

我通过重用您有问题的代码,使用Ionic Example创建了小吃。 请同时检查项目中package.json和expo sdk中的版本。 https://snack.expo.io/@djalik/ionicons