简体   繁体   English

React 本机应用程序未呈现组件

[英]React native app is not rendering the component

I am getting this error: error message我收到此错误:错误消息

Not really sure what I did wrong because everything looks right with my code, at least if I missed something.不太确定我做错了什么,因为我的代码看起来一切正常,至少如果我错过了什么。

import React, { useState } from "react";
import Home from "./screens/home";
import { View } from "react-native";
import * as Font from "expo-font";
import { AppLoading } from "expo-app-loading";

const getFonts = () =>
  Font.loadAsync({
    "poppins-regular": require("./assets/fonts/Poppins-Regular.ttf"),
    "poppins-bold": require("./assets/fonts/Poppins-Bold.ttf"),
  });

export default function App() {
  const [fontsLoaded, setFontsLoaded] = useState(false);
  if (fontsLoaded) {
    return <Home />;
  } else {
    return (
      <AppLoading startAsync={getFonts} onFinish={() => setFontsLoaded(true)} />
    );
  }
}

Can you try changing你能尝试改变吗

import { AppLoading } from "expo-app-loading";

to this:对此:

import AppLoading from 'expo-app-loading';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM