React Native TypeError:undefined不是对象(计算“y.Font. isLoaded”)

mwkjh3gx  于 2023-03-03  发布在  React
关注(0)|答案(1)|浏览(160)

我正在用handlebarlabs开发货币转换器应用程序课程。我正尝试通过从@expo/vector-icons导入Ionicons来添加图标到我的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
ltqd579y

ltqd579y1#

我创建了小吃与 Ionic 例子,通过重用您的代码,是张贴在问题。请检查版本在package.json和expo sdk在您的项目也。https://snack.expo.io/@djalik/ionicons

相关问题