Git Product home page Git Product logo

this error appear when i run my app: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. about react-native-tutorial HOT 3 OPEN

iamshaunjp avatar iamshaunjp commented on July 17, 2024
this error appear when i run my app: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

from react-native-tutorial.

Comments (3)

furkanbk avatar furkanbk commented on July 17, 2024 2

Hello. Please type this in the command pannel:
expo install expo-app-loading
Also, do not destructure AppLoading while importing. Use:
import AppLoading from 'expo-app-loading';
Finally, do not forget onError prompt of AppLoading. Use it like this:
<AppLoading startAsync = {getFonts} onFinish = {() => setFontsLoaded(true)} onError={() => console.log('error')} />

from react-native-tutorial.

jasonleewimi avatar jasonleewimi commented on July 17, 2024

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

const getFonts = () => {
return Font.loadAsync({
'nunito-regular': require('./assets/fonts/Nunito-Regular.ttf'),
'nunito-bold': require('./assets/fonts/Nunito-Bold.ttf')
});
}

export default function App() {
const [fontsLoaded, setFontsLoaded] = useState(false);

if(fontsLoaded){
return (

);
}else {
return(
<AppLoading
startAsync = {getFonts}
onFinish = {() => setFontsLoaded(true)}
/>
);
}
}`

from react-native-tutorial.

efosblack avatar efosblack commented on July 17, 2024

use this code in your App.js file instead after pasting your custom fonts in your assets/fonts folder.

import { useCallback } from 'react';
import { useFonts } from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import Home from './screens/home';
import {View} from 'react-native';

SplashScreen.preventAutoHideAsync();

export default function App() {
const [fontsLoaded, fontError] = useFonts({
'Nunito-Bold': require('./assets/fonts/Nunito-Bold.ttf'),
'Nunito-Regular': require('./assets/fonts/Nunito-Regular.ttf'),

});

const onLayoutRootView = useCallback(async () => {
if (fontsLoaded || fontError) {
await SplashScreen.hideAsync();
}
}, [fontsLoaded, fontError]);

if (!fontsLoaded && !fontError) {
return null;
}
return (



);
}

from react-native-tutorial.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.