Тёмный

React Native Tutorial #17 - Custom Fonts 

Net Ninja
Подписаться 1,6 млн
Просмотров 101 тыс.
50% 1

Опубликовано:

 

12 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 165   
@swapnilsagar3805
@swapnilsagar3805 3 года назад
For those viewing the videos now, Expo no longer supports import AppLoading from "expo", It has changed to import AppLoading from "expo-app-loading"; also, you'll required onError method inside AppLoading as below. setFontsLoaded(true)} onError={console.warn} />
@lucasknudsen7236
@lucasknudsen7236 3 года назад
cheers!
@tolu-john
@tolu-john 3 года назад
If you are getting an error with the AppLoading Component run expo install expo-app-loading and the replace import { AppLoading } from 'expo'; with import AppLoading from 'expo-app-loading'; The AppLoading component was separated in newer versions of expo
@prafulrane3591
@prafulrane3591 Год назад
It's giving warning ⚠️
@juliorodriguez4946
@juliorodriguez4946 6 месяцев назад
its because it's deprecated and now you can use expo-splash-screen instead, however AppLoading still works; just add an onError attribute like this: setFontsLoaded(true)} onError={(err) => console.log(err)} />
@mohammedmoatasem2073
@mohammedmoatasem2073 5 месяцев назад
@@juliorodriguez4946 This was super helpful !
@favour_live
@favour_live 3 года назад
Net Ninja's code wouldn't work now. You will run into errors while using AppLoading etc. You will need to import AppLoading like so. import AppLoading from 'expo-app-loading' . In the AppLoading component, you will also need to and an onError prop. This should take care of it. onError={console.warn}. Here is my fully working code. import React, { useState } from 'react'; import * as Font from 'expo-font'; import Home from './screens/home'; import AppLoading from 'expo-app-loading'; const getFonts = () => 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 ( setFontsLoaded(true)} onError={console.warn} /> ) } }
@jasonkim7732
@jasonkim7732 3 года назад
saved me!
@dev2773
@dev2773 3 года назад
@@jasonkim7732 great job, AppLoading is not object anymore.
@tuetktran9477
@tuetktran9477 3 года назад
Thank you so much!
@Nalan-ur6qk
@Nalan-ur6qk 2 месяца назад
ty so much
@tzofiyahariel5120
@tzofiyahariel5120 3 года назад
THANKYOU! after sitting for several hours trying to use custom fonts in react native i finally found your video!
@flykeymikey4106
@flykeymikey4106 4 года назад
Amazing tutorial, JUST what I was looking for! I love how you use Functional Components instead of complicated Class Based ones Thank you!!!!!!!!!!!!!!!!
@ahmadalfan9022
@ahmadalfan9022 3 года назад
In case you are having error, try this solution instead (worked for me): 1. Open terminal and install: $ expo install expo-font $ expo install expo-app-loading 2. Use this code instead: import React from 'react'; import { useFonts } from 'expo-font'; import AppLoading from 'expo-app-loading'; import Home from './screens/Home'; export default function App() { let [fontsLoaded] = useFonts({ regular: require('./assets/fonts/Nunito-Regular.ttf'), bold: require('./assets/fonts/Nunito-Bold.ttf'), }); if (!fontsLoaded) { return ; } else { return ; } } useFonts() works perfectly in my case, feel free to experiment with another method from the documentation.
@emmanuelessien8286
@emmanuelessien8286 Год назад
Thank you for this, i just applied it and it work well for me
@wilsonb4175
@wilsonb4175 4 года назад
In case someone wonder how Home applies the font, is because when fontsLoaded is edited, Home component is re render automatically.
@saravanasai2391
@saravanasai2391 3 года назад
" useEffect(() => { getFont().then(()=>setfontsLoaded(true)) }, []) " use this its best alternative for that AppLoading component ...i have faced a lots of erros on using AppLoading
@manuelpascual7063
@manuelpascual7063 4 года назад
Could be possible to achieve this by using useEffect?? Thanks for everything mate!
@sebiplayzz4541
@sebiplayzz4541 4 года назад
They updated the documentation and you can now import a custom hook to use the fonts
@fernandogomez83
@fernandogomez83 4 года назад
Same here. I used it and worked the same.
@lordstorm7237
@lordstorm7237 3 года назад
That's what I did and it worked no problem
@Mahmoudery
@Mahmoudery 8 месяцев назад
Class components are my favorite because they're so flexible and potent of doing more than the functional component.
@tugaybaslk5158
@tugaybaslk5158 3 года назад
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. Check the render method of `App` :(
@satvic__vichar
@satvic__vichar 3 года назад
im getting the same error . plz help if you find a fix
@robimegu3712
@robimegu3712 3 года назад
Sorry guys, I can't help you. I got the same error... If you find out what is the solution please give me a feedback.
@satvic__vichar
@satvic__vichar 3 года назад
@@robimegu3712 no worries , my error got fixed, I misspelled ".ttf" as ".tff"
@tugaybaslk5158
@tugaybaslk5158 3 года назад
@@satvic__vichar :D
@mreddygi
@mreddygi 3 года назад
got the same errror
@leofaizan8886
@leofaizan8886 3 года назад
if you get any errors regarding the installation of expo-app-loading , open cmd as administrator and go to the project directory and then run 'expo install expo-app-loading' instead of installing it from your editor's terminal.
@Badopisa
@Badopisa 3 года назад
Mine can't import AppLoading.. showing error
@ashwin9679
@ashwin9679 2 года назад
This worked, thanks a lot.
@gamerdin1384
@gamerdin1384 2 года назад
Worked for me, Ty sir
@BamatoPvP
@BamatoPvP 3 года назад
I got some errors because of my files and folders but I solved them and it finally worked ! Thank you so much.
@amoshnin
@amoshnin 4 года назад
The Net Ninja, your tutorials are brilliant!
@d3vfc334
@d3vfc334 2 года назад
If you are learning like me in 2022 : Here you should make a small modification like so : - After running this command : > expo install @expo-google-fonts/inter expo-font > expo install expo-app-loading - Delete node_modules folder and run : > npm install or yarn install And do this 👇👇👇👇👇👇👇 ------------------------------------------------------------------------------------------------------ 1 - import useFont: import { useFonts } from 'expo-font'; ------------------------------------------------------------------------------------------------------ 2 - Change import app loading location : import AppLoading from 'expo-app-loading'; ------------------------------------------------------------------------------------------------------ 3 - Change the getFont function to : const getFont = () => useFonts({ 'Nunito-Bold': require('./assets/fonts/Roboto-Bold.ttf'), }) ------------------------------------------------------------------------------------------------------ 4 - My conditions : if (fontsLoaded) { return ( ); } else { return ( ) } 5 - have a nice day ;p and don't forget Ninja is the best Good Code.....
@sidimariko1
@sidimariko1 2 года назад
It’s work for me.
@sciencenerd8326
@sciencenerd8326 3 года назад
For those who are watching now! You don't need to download the fonts. First import it like this: "expo install @expo-google-fonts/nunito expo-font" import React from 'react'; import Home from './screens/Home'; import { StyleSheet, Text, View } from 'react-native'; import { useFonts, Nunito_400Regular, Nunito_700Bold } from '@expo-google-fonts/nunito'; export default function App() { let [fontsLoaded] = useFonts({ Nunito_700Bold, Nunito_400Regular, }); if (!fontsLoaded) { return ( Internet Required! ) } else { return ( ); } } const styles = StyleSheet.create({ container: { padding: 50, flex: 1, textAlignVertical: "center", } })
@andreivandrummer
@andreivandrummer 4 года назад
Hello! Thanks for the tutorial :) Do you have any article of including Custom Fonts with react-native-cli?
@AI913
@AI913 4 года назад
I have the same question too!
@usamamashkoor3861
@usamamashkoor3861 4 года назад
Yes, me to
@muhammadmujtaba7817
@muhammadmujtaba7817 3 года назад
Guys now the expo documentation is updated so install the following package given below expo install expo-app-loading and then copy this code given below import React, { useState } from "react"; import Home from "./screens/home"; import * as font from "expo-font"; import AppLoading from 'expo-app-loading'; const getFonts = () => { return font.loadAsync({ "Nunito-Bold": require("./assets/fonts/Nunito-Bold.ttf"), "Nunito-Regular": require("./assets/fonts/Nunito-Regular.ttf") }) } export default function App() { const [fontsLoaded, setFontsLoaded] = useState(false) if (fontsLoaded) { return ( ) } else { return ( setFontsLoaded(true)} onError={()=>console.log("error")} /> ) } }
@valerioMentality
@valerioMentality 3 года назад
thank you so much man 💪
@cesarpeeters8049
@cesarpeeters8049 4 года назад
Thank you, very clear tutorial. Love it!
@afro_habesha
@afro_habesha Год назад
can we use useFont hook instead of the use state const [fontsLoaded] = useFonts({ 'Nunito-Bold': require('./assets/fonts/Nunito-Bold.ttf'), 'Nunito-Regular': require('./assets/fonts/Nunito-Regular.ttf'), }); it works
@zidrexandag06
@zidrexandag06 3 года назад
What if not using expo? what is the AppLoading equivalent?
@TheAdel136
@TheAdel136 3 года назад
for those who had this kind of message error : you started loading the font nunito-bold but used it before it finished loading .... just add this line of code in your getFont function like this => const getFont= async()=>{ await Font.loadAsync({ 'nunito': require('./assets/fonts/Nunito-Bold.ttf') })}
@emilypark8144
@emilypark8144 2 года назад
thank you so much!! Exactly what I was looking for.
@PhilScottCanada
@PhilScottCanada Год назад
Quick Question: Any reason why not to just add the custom font as an asset in the React-Native package.json file? "rnpm": { "assets": [ "./assets/fonts/" ] }
@mohammadfoisal4873
@mohammadfoisal4873 2 года назад
how can i add fonts in non expo project????
@tyland777
@tyland777 4 года назад
Best tutorial on Custom Fonts
@jonathanhirshowitz722
@jonathanhirshowitz722 4 года назад
Hey Ninja, can you explain why font is different than all other imports in the way that it it's downloaded by 'App' and then can by used across the entire project?
@brittneypostma
@brittneypostma 4 года назад
I noticed when just doing this course that when importing the fonts I ran into an error. I had to create a react-native.config.js file to import them. Anyone else?
@DilpreetSingh-pd6co
@DilpreetSingh-pd6co 3 года назад
yes
@thatolebethe3238
@thatolebethe3238 3 года назад
Please help with this step
@dannyman2200
@dannyman2200 3 года назад
why cant we just make the getFonts function synchronous?
@fernandogomez83
@fernandogomez83 4 года назад
The tutorial is awesome!
@paoloranit8834
@paoloranit8834 2 года назад
you can study the splashscreen instead as apploader is now deprecated
@aseemlalfakawma5084
@aseemlalfakawma5084 3 года назад
I don't know, but I feel like the way this is being done is not the optimal way to do it. Cause there is the fontWeight property that can be set in the StyleSheet, what about that? I don't want to go about defining each font appending it's 'weight' at the end, there has to be another way to import the font so we can use fontWeight: '700', and it uses the Bold font, and so on.
@BaseTechTopVideos
@BaseTechTopVideos 3 года назад
This might help to whoever having issues with "Metro has encountered an error: While trying to resolve module `expo-app-loading` " or stuck at "Running application on Android SDK built for x86 stuck" and "fontFamily "nunito-regular" is not a system font. import React from "react"; import { StyleSheet, Text, View } from "react-native"; import AppLoading from "expo-app-loading"; import { useFonts } from "@use-expo/font"; export default function App() { const [isLoaded] = useFonts({ "BerkshireSwash-Regular": require("./assets/fonts/BerkshireSwash-Regular.ttf"), }); if (isLoaded) { return ( Custom Fonts ); } else { return ; } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: "center", alignItems: "center", }, }); Some module like AppLoading import from 'expo' is no more.
@yacinefaraday239
@yacinefaraday239 Год назад
thank you
@unity_with_timoteo
@unity_with_timoteo 4 года назад
Hello Ninja. U are awesome!! I would like to ask u: Can i take your videos and make up a tutorial based on your video structure? I am Brazilian and the videos will be in Portuguese. Thanx a lot!!
@LucasZaranza
@LucasZaranza 4 года назад
Cara, seria incrível! Massa ver outro BR por aqui. Net Ninja realmente manja, seria massa algum conteúdo assim no nosso idioma, vai fundo hehe
@pedrobrasil892
@pedrobrasil892 4 года назад
Pq vc não traduz?
@saurabhjain2161
@saurabhjain2161 4 года назад
Apploading call setfontsLoaded when loading is completed. Can you please explain, how react-native controls flow back to the if condition to check if fontsLoaded is true.
@RADIOSCATRACHASUTAN
@RADIOSCATRACHASUTAN Год назад
Since I am new to RN, I would async the function and do the state, I dont use Expo I guess I should but I dont want to go back and start from beginning.
@iltanoia6865
@iltanoia6865 3 года назад
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: null.
@josifhamed4474
@josifhamed4474 3 года назад
UPDATE: use "import AppLoading from 'expo-app-loading';" at the top after installation (expo install expo-app-loading). Also, besides onFinish, also use onError={console.warn} (i copy pasted the first comment from the video)
@LotfiORouis
@LotfiORouis 3 года назад
Awesome as usual! Just an update: now Apploading is imorted like that: import AppLoading from "expo-app-loading";
@super-legend
@super-legend 4 года назад
Font family "foo-bar" is not a system font and has not been loaded through Font.loadAsync. ☹️☹️☹️☹️ Can i get solution for this?
@ShubhamKumar-dp3ex
@ShubhamKumar-dp3ex 4 года назад
Try this piece of code for app.js import React from 'react'; import { AppLoading } from 'expo'; import { Container, Text } from 'native-base'; import * as Font from 'expo-font'; import { Ionicons } from '@expo/vector-icons'; export default class App extends React.Component { constructor(props) { super(props); this.state = { isReady: false, }; } async componentDidMount() { await Font.loadAsync({ Roboto: require('native-base/Fonts/Roboto.ttf'), Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'), ...Ionicons.font, }); this.setState({ isReady: true }); } render() { if (!this.state.isReady) { return ; } return ( Open up App.js to start working on your app! ); } }
@super-legend
@super-legend 4 года назад
@@ShubhamKumar-dp3ex thanks so much for the reply but i got the solution for it we just have to use useFont hook and things get on track👍👍👍🙂🙂🙂
@ShubhamKumar-dp3ex
@ShubhamKumar-dp3ex 4 года назад
@@super-legend that's nice 🎉
@whonayem01
@whonayem01 3 года назад
Thanks. It helped.
@MShamkhal
@MShamkhal Год назад
It didn't work for me, maybe because this is an outdated form of importing fonts. I have found another solution using useFonts() hook: import React from 'react'; import { View, Text } from 'react-native'; import { useFonts } from 'expo-font'; import Home from './screens/home'; export default function App() { const [fontsLoaded] = useFonts({ "nunito-regular": require("./assets/fonts/Nunito-Regular.ttf"), "nunito-bold": require("./assets/fonts/Nunito-Bold.ttf"), }); if (!fontsLoaded) { return ( Loading fonts... ); } else { return ( ); } }
@kazirafidraiyan2553
@kazirafidraiyan2553 Год назад
Cheers! Thanks for the help.
@MShamkhal
@MShamkhal Год назад
@@kazirafidraiyan2553 you're welcome👌
@Cardonfamily
@Cardonfamily 7 месяцев назад
Thanks! I tried a number of different options, including what was given on Expo Docs Fonts page. This was the first thing that worked for me.
@fluxsiarski
@fluxsiarski 7 месяцев назад
This film is unfortunately already deprecated.
@abhishekgadewar4616
@abhishekgadewar4616 Год назад
got this working only after using useFonts as provided in Expo Font documentation
@aperturemaker
@aperturemaker Год назад
Using this code, it run perfectly : import * as React from 'react'; import * as Font from 'expo-font'; import Home from './screens/home'; export default class App extends React.Component { constructor(props) { super(props); this.state = { fontsLoaded: false } } async loadFonts() { await Font.loadAsync({ 'nunito-bold': require('./assets/fonts/Nunito-Bold.ttf'), }); this.setState({ fontsLoaded: true }); } componentDidMount() { this.loadFonts(); } render() { if (this.state.fontsLoaded) { return ( ); } else { return null; } } }
@IonutBarbu
@IonutBarbu 11 месяцев назад
This works.
@martiny1785
@martiny1785 3 года назад
You could just go to the styles and do this: text:{ fontFamily: 'nunito-bold', fontSize: 18, } It also works
@golovnaya_boly
@golovnaya_boly 4 года назад
helped a lot,thx
@LumbreraEnMiCamino
@LumbreraEnMiCamino 4 года назад
Unable to resolve "./assets/fonts/
@vaibhavchandra5897
@vaibhavchandra5897 3 года назад
check the path again. i had the same error and then noticed that the path i had written was wrong.
@musiclub143
@musiclub143 3 года назад
9:13 that's because stupidly loll
@rialf5373
@rialf5373 4 года назад
A path in an 'extends' option must be relative or rooted, but 'expo-module-scripts/tsconfig.base' is not. this error message from vscode but still okay(running app) this is bug?
@emmanuelgasante4509
@emmanuelgasante4509 3 года назад
Hello please I'm following your tutorials and everything is going fine until this point where im getting an error that says that element is invalid when i try to use a custom font
@amanxsharma20
@amanxsharma20 3 года назад
It didn't work for me and if it didn't work for you too then use this, hope it helps : app.js - import React from 'react'; import { Text, View } from 'react-native'; import { useFonts } from 'expo-font'; import Home from './screens/home' export default props => { let [fontsLoaded] = useFonts({ 'Nunitobold': require('./assets/fonts/Nunitobold.ttf'), 'NunitoRegular': require('./assets/fonts/NunitoRegular.ttf'), }); return ( ); }; home.js - import React from 'React'; import { StyleSheet, View, Text } from 'react-native'; export default function Home() { return ( Home Screen ) } const styles = StyleSheet.create({ container: { padding: 24, }, titleText: { fontFamily: 'Nunitobold', fontSize: 18, } }); (keep the .ttf font file name and the name in code same obviously)
@codebase_dev
@codebase_dev 3 года назад
Right
@iam3rillz
@iam3rillz 4 года назад
Hi...Please, how do you go about this if you are not using expo? I mean using CLI
@krishnakantmodani353
@krishnakantmodani353 3 года назад
FACING THIS ISSUE...CAN ANYONE HELP? fontFamily "nunito-bold" is not a system font and has not been loaded through Font.loadAsync. - If you intended to use a system font, make sure you typed the name correctly and that it is supported by your device operating system. - If this is a custom font, be sure to load it with Font.loadAsync.
@ນາງຫມູ່ຫລານ
try import font from the top instead of using require method like below: import React, { useState } from "react"; import * as Font from "expo-font"; import Home from "./screens/home"; import AppLoading from 'expo-app-loading'; import Defago from './assets/fonts/DefagoNotoSans.ttf'; const getFonts = () => { return Font.loadAsync({ 'Defago': Defago, }); }; export default function App() { const [fontLoaded, setFontLoaded] = useState(false); if (fontLoaded) { return ( ); } else { return ( setFontLoaded(true)} onError={console.warn}/> ); } }
@krishnakantmodani353
@krishnakantmodani353 3 года назад
@@ນາງຫມູ່ຫລານ Hey thanks, it worked!
@evanderbermudez180
@evanderbermudez180 10 месяцев назад
the custom fonts has an error and i dont know to fix it
@salemouail627
@salemouail627 4 года назад
for people using cli instead of expo ================ 1/make a folder in root app as : assets then fonts folder in assets and put .ttf fonts inside it(./assets/fonts/fontname.ttf) 2/make a file in root and name it: react-native.config.js and pass this inside it. module.exports = { project: { ios: {}, android: {}, }, assets: ['./src/assets/fonts/'], }; 3/ run : npx react-native link 4/ run : npx react-native run-android (u have to rebuilt the app) 5/ u can now use your font style={{ fontFamily: "fontname" }}
@danielstoicamusic
@danielstoicamusic 4 года назад
So useEffect would not have worked for this?
@Fullflexno
@Fullflexno 4 года назад
Thank you for this, Ninja!
@petera2c898
@petera2c898 4 года назад
I get this error: - fontFamily "nunito-regular" is not a system font and has not been loaded through Font.loadAsync. - If you intended to use a system font, make sure you typed the name correctly and that it is supported by your device operating system. - If this is a custom font, be sure to load it with Font.loadAsync. I followed the guide carefully and tried many stack overflow solutions. Any help is appreciated.
@Bouex
@Bouex 4 года назад
Same here :(
@kartikvyas5338
@kartikvyas5338 4 года назад
Same here. Someone kindly help, will be obliged!!
@satwantkaur7220
@satwantkaur7220 4 года назад
u tell about the expo and how we can do for the real devices
@DrNabeel20
@DrNabeel20 3 года назад
Thank you 👏
@deniseleinonen6532
@deniseleinonen6532 3 года назад
My text doesn’t show. Does anyone else had the same problem and how did you solve it?
@pq8856
@pq8856 4 года назад
thanks so much!!!!!!!!!!!!!!!!!!!
@maurocortes469
@maurocortes469 3 года назад
Thanks !
@zohaibanwar2605
@zohaibanwar2605 4 года назад
Unable to resolve "./assests/fonts/Nunito-Regular.ttf" from "App.js" this error is appearing in App builder
@LumbreraEnMiCamino
@LumbreraEnMiCamino 4 года назад
same error any solution?
@greenjd3700
@greenjd3700 3 года назад
did you find the answer?
@greenjd3700
@greenjd3700 3 года назад
make sure you are using "useState" correctly
@mihailojovanovic2197
@mihailojovanovic2197 3 года назад
Error "Check the render method of 'App' "
@alexandergrebennikov7778
@alexandergrebennikov7778 4 года назад
I did all of that but font does not change ( No errors, nothing... (
@justinuzzanti361
@justinuzzanti361 4 года назад
If your using a AVD you might want to close it and open a new one. for some reason if i have had mine up for a while it just stops working and get buggy.
@alexandergrebennikov7778
@alexandergrebennikov7778 4 года назад
@@justinuzzanti361 I use physical device
@begoalibasic841
@begoalibasic841 4 года назад
is your code on github, can you give a link to repo if you are not yet resolved the issue?
@alexandergrebennikov7778
@alexandergrebennikov7778 4 года назад
@@begoalibasic841 Did not resolve yet... github.com/grebennikovalex/XO/blob/master/App.js Thank you )
@alexandergrebennikov7778
@alexandergrebennikov7778 4 года назад
@@begoalibasic841 Custom font appeared only in Input field... as an input string and as well as a placeholder ) weird...
@msvmanikantasrivishnu7788
@msvmanikantasrivishnu7788 4 года назад
Do you have any courses?
@manoj-k
@manoj-k 2 года назад
🔥🔥🔥
@DilpreetSingh-pd6co
@DilpreetSingh-pd6co 3 года назад
Building JavaScript bundle: error ERROR 14:13 Unable to resolve module expo-app-loading from J:\React_Native_Projects\gameZone\App.js: expo-app-loading could not be found within the project. If you are sure the module exists, try these steps: 1. Clear watchman watches: watchman watch-del-all 2. Delete node_modules and run yarn install 3. Reset Metro's cache: yarn start --reset-cache 4. Remove the cache: rm -rf /tmp/metro-* 3 | import * as Font from 'expo-font'; 4 | import Home from './screens/home'; > 5 | import { AppLoading } from 'expo-app-loading'; | ^ 6 | 7 | const getFont = () => Font.loadAsync({ 8 | 'nunito-regular': require('./assets/fonts/Nunito-Regular.ttf'),
@sidharthpunathil
@sidharthpunathil 4 года назад
What does .loadAsync do?
@dibyendusaha8711
@dibyendusaha8711 Год назад
useFonts made it easier
@raievepic9967
@raievepic9967 3 года назад
Hello, i just wasted about 3 to 4 hours realizing why my fonts didnt work corectly and would like to advise whoever could fit: be sure your fonts file name is as simple as possible, mine wasnt woring due a "=" signal on it also, in else section add the onError prop >>>> onError={ () => getFonts } it should look like this: else { return( getFonts} onFinish={()=>setFontsLoaded(true)} /> ) } Either, if the error persists, try creating a new project using ONLY expo tools; like when you add a new package in your cmd, use ever the > expo install whatever-package-name-is-comes-here < i have had some issues due installing some libraries from using EXPO INSTALL and some using NPM INSTALL chose one of the installation methods for the whole project
@navpreetkaur8801
@navpreetkaur8801 3 года назад
Thanks a lot. This code helped me in getting rid of the error too! The error was " apploading threw an unexpected error when loading:"
@msvmanikantasrivishnu7788
@msvmanikantasrivishnu7788 4 года назад
Nice
@samrahmazhar2716
@samrahmazhar2716 3 года назад
I am unable to solve this error. if anybody can solve it, I will be very helpful F:/FYP/apps/gamezone/node_modules/expo-splash-screen/build/index.js Error: ENOENT: no such file or directory, open 'F:\FYP\apps\gamezone ode_modules\expo-splash-screen\build\index.js' This error occurred during the build time and cannot be dismissed.
@jamalxd5647
@jamalxd5647 Год назад
not work in me, thanks for the tutorial
@xiaotingshao3689
@xiaotingshao3689 Год назад
not working on me, I think have to study splash screen
@xiaotingshao3689
@xiaotingshao3689 Год назад
I didn't use splash screen to optimize the render, just the code below I used to import the custom font work as well. const customerFonts={ 'Inter-Black': require('./assets/fonts/Inter-Black.ttf'), 'Inter-Light': require('./assets/fonts/Inter-Light.ttf'), 'Inter-Medium': require('./assets/fonts/Inter-Medium.ttf'), 'Inter-Regular': require('./assets/fonts/Inter-Regular.ttf'), } export default function App() { const [fontLoaded, setFontLoaded] = useState(false) useEffect(()=>{ const getFonts=async()=>{ try{ await Font.loadAsync(customerFonts) }catch(e){ console.warn(e); }finally{ setFontLoaded(true) } } getFonts(); },[]) wrap the app in the fontLoaded condition is true, else return null.
@shadmanmartinpiyal4057
@shadmanmartinpiyal4057 4 года назад
I encountered a problem with expo-splash-screen. Anybody having this problem simply run "npm install --save expo-splash-screen" It will save it as a dependency in the package.json. Thanks
@ermirakajtazi5841
@ermirakajtazi5841 3 года назад
I would not recommend this way of using styles because the whole time this was the reason that my app keep reloading. Sorry!
@dannyman2200
@dannyman2200 3 года назад
Expo has been updated, you WILL get an error go down to Ovos Odius comment to fix
@codebase_dev
@codebase_dev 3 года назад
Didn't worked 🥺
@amanxsharma20
@amanxsharma20 3 года назад
+1
@codebase_dev
@codebase_dev 3 года назад
@@amanxsharma20 I solved apploadig component error
@amanxsharma20
@amanxsharma20 3 года назад
@@codebase_dev I also had the same error. I just deleted the app loading thing and it worked fine afterward. maybe sort the comments by recent and check my recent comment and provide some insights if u can. I've pasted the whole code.
@Arkillus
@Arkillus 2 года назад
very useful
@saurabhjain2161
@saurabhjain2161 4 года назад
It works for me even without return statement in else block. I dont know how...
@nguyenngochai0z
@nguyenngochai0z 3 года назад
useEfeect so ez
@80Vikram
@80Vikram 3 года назад
Why can't I just import font from google like we do with normal html and css project ?
Далее
React Native Tutorial  #18 - Global Styles
5:58
Просмотров 80 тыс.
React Native Tutorial  #14 - Flexbox Basics
18:43
Просмотров 134 тыс.
when you have plan B 😂 @andreyreactions
00:11
Просмотров 1,1 млн
The New React Native Architecture
25:59
Просмотров 139 тыс.
~/.dotfiles in 100 Seconds
13:54
Просмотров 418 тыс.
Top 30 Flutter Tips and Tricks
6:50
Просмотров 554 тыс.
React Native Tutorial  #20 - Stack Navigator
12:07
Просмотров 269 тыс.
Role Based Navigation in React Native with Expo Router
25:41