[英][Unhandled promise rejection: ReferenceError: Can't find variable: auth]
[英]Custom font React-Native, [Unhandled promise rejection: ReferenceError: Can't find variable: ExpoFontLoader]
我正在尝试在我的 react-native 应用程序中实现自定义字体。 我遵循了世博会的文档,但收到一条错误消息:
[Unhandled promise rejection: ReferenceError: Can't find variable: ExpoFontLoader]
node_modules/expo-font/build/Font.js:103:25 in _loadSingleFontAsync$
node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
... 14 more stack frames from framework internals
这是我来自Login.js
代码
import React, {useState} from 'react'
import { StyleSheet, Text, View, Button, TextInput } from 'react-native'
//import firebase and it's auth module
import firebase from 'firebase/app';
import 'firebase/auth';
import * as Font from 'expo-font';
export default class Login extends React.Component {
constructor(){
super()
this.state={
fontLoaded:false
}
}
async componentDidMount() {
await Font.loadAsync({
'play': require('../assets/fonts/PressStart2P-Regular.ttf'),
});
this.setState({ fontLoaded: true });
}
render() {
return (
<View style={styles.container}>
{this.state.fontLoaded ? (
<Text style={styles.title}>Login</Text>
) : null
}
我从未使用过变量: ExpoFontLoader
,我找不到有关此错误的其他信息。 使用字体登录的文本未显示,我找不到方法...谁能帮助我?
我自己修复了它,出于某种原因,当我安装 expo 时,它从 expo-font 中获取了 7.0.0 版。 这必须是 8.0.0 版,所以我安装了正确的版本,现在它可以工作了!
检查您是.ttf
文件路径。
我发现了类似这个错误的东西:https ://github.com/expo/expo/issues/4626#issuecomment-503138343
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.