-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fontFamily 'Roboto_medium' is not a system font and has not been loaded through Exponent.Font.loadAsync #1466
Comments
Googling for that "used it before it finished loading" error came with this SO post, which gave me the workaround: Basically, I had to delay rendering of my top-level component until the font has been loaded, like so: import React, { Component } from "react";
import { Root } from "native-base";
import { Font, AppLoading } from "expo";
class HomeNav extends Component {
constructor(props) {
super(props);
this.state = { loading: true };
}
async componentWillMount() {
await Font.loadAsync({
Roboto: require("native-base/Fonts/Roboto.ttf"),
Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf")
});
this.setState({ loading: false });
}
render() {
if (this.state.loading) {
return (
<Root>
<AppLoading />
</Root>
);
}
return (
<Root>
<AppNavigator />
</Root>
);
}
} I'm not happy that you have to put in Expo-level hacks like this, but it is, at least, only on one component. |
For anyone still having issues, the following worked for me:
|
Hmm I'm having this issue, not finding a solution yet :( |
Same issue - Started loading and used before finished loading - But copied code exactly as above. Looks like still issue. |
For me it turned out to be a completely unrelated issue. In fact, a lot of time when my expo app throws an error, it shows the error above. Once I fix the issue, the error about exponent loading the font goes away too. I wonder if this means that the error is always there but masked by something else? Or if expo is throwing this error incorrectly when it's supposed to show the actual place of error/crash. |
After cobbling together bits and pieces on loading the icons for react-native-elements I finally figured this out. Check out my blog for a write-up. |
Loading the app in the Expo client in Android triggers red screen with error
If's simple test app, just displaying an Native-base card. Works fine on iOS. Even in Android, I can see it display the NativeBase card briefly before it red screens. I am loading the font as per the instructions in the readme:
Update
After posting this, I noticed that the readme uses
componentWillMount
rather thancomponentDidMount
. When I changed my code accordingly though, I get the errorThe text was updated successfully, but these errors were encountered: