Reputation: 195
fontFamily "pro" is not a system font and has not been loaded through Font.loadAsync.
But if I dismiss the error I see that the font has loaded.
Here is my code:
export default class App extends Component {
constructor(props) {
super(props);
this.state = {loading: true};
}
async componentDidMount() {
await Font.loadAsync({
pro: require('./assets/fonts/MavenPro-Regular.ttf'),
medium: require('./assets/fonts/MavenPro-Medium.ttf'),
}).then(() => {
this.setState({loading: false});
});
}
render() {
return (
<Provider store={store}>
<NavigationContainer>
{
<Drawer.Navigator
drawerType={'slide'}
drawerContent={(props) => <DrawerContent {...props} />}>
<Drawer.Screen
name="Home"
component={HomeStackScreen}
options={{
swipeEnabled: false,
}}
/>
</Drawer.Navigator>
}
</NavigationContainer>
</Provider>
);
}
}
Upvotes: 1
Views: 2095
Reputation: 8038
you're not delaying presenting the app based on the loading state, so you are rendering the app before the font has loaded, thus the error.
notice in this example that the AppLoading
component is rendered while loading fonts, you can use this if you want, or whatever else you would like to display.
also, not related to your question but fyi you don't need to use then()
if you're using await
await doSomething();
this.setState({ done: true });
Upvotes: 1