I'm using Expo Google Fonts and the useFonts() method to import the fonts for my app. However I get the following error but I thought I didn't need to use Font.loadasync with the Google Fonts (as per docs here). Can you let me know what I'm doing wrong here?
import React, { useState } from "react";
import { View, TouchableOpacity, Text, StyleSheet, Platform } from 'react-native'
import { useFonts, Kanit_400Regular, Kanit_500Medium, Kanit_700Bold } from '@expo-google-fonts/kanit';
import Colors from '../constants/Colors'
const Header = props => {
  useFonts({Kanit_400Regular, Kanit_500Medium, Kanit_700Bold})
  return (
    <View style={styles.headerContainer}>
      <View style={styles.logo}>
        <Text style={styles.headerText}>HEADER</Text>
      </View>
      <View>
        <Text style={{...styles.headerText, fontSize: 14 }}>LOGIN</Text>
      </View>
    </View>
  )
} 
const styles = StyleSheet.create({
  headerContainer: {
    padding: 15,
    paddingTop: Platform.OS === 'android' ? 40 : 15,
    backgroundColor: 'rgba(0,0,0,0.3)',
    justifyContent: 'space-between',
    height: Platform.OS === 'android' ? '12%' : '10%',
    borderBottomColor: Colors.borderGold,
    borderBottomWidth: 1,
    alignItems: 'center',
    flexDirection: 'row',
    fontSize: 16,
  },
  headerText: {
    fontSize: 16,
    color: Colors.primary,
    fontFamily: 'Kanit_500Medium',
  }
})
export default Header

In my case the problem was an incompatible version of expo-font in the package.json with the version of expo installed.
I downgraded from 10.1.0 to 10.0.4 and the fonts are now loading fine.
Remember to use expo install expo-font
I hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With