Closed frgomes closed 6 years ago
I've posted the results of my tests in Expo foruns: https://forums.expo.io/t/cannot-load-font-from-expo-vector-icons/4752
[SOLVED] At the moment, the easiest solution is loading fonts (and eventually other resources) when the application starts, still in the JS land. This is far from ideal, since we should address the issue in the ScalaJS land. However, it's enough for the time being.
App.js:
import React from 'react';
import { Font, AppLoading } from 'expo';
import * as sjs from './assets/js/scalajs-output-android.js';
export default class App extends React.Component {
state = {
fontsLoaded: false,
};
async componentWillMount() {
await Font.loadAsync({
'MaterialIcons': require('@expo/vector-icons/fonts/MaterialIcons.ttf')
});
this.setState({ fontsLoaded: true });
};
render() {
if (!this.state.fontsLoaded) {
return <AppLoading />;
}
// Choose one of: "default_root", "stackNavigation_root", "tabNavigation_root", "drawerNavigation_root", ...
const component = sjs.default_root();
return (React.createElement(component, {}));
}
}
It's now fixed on branch https://github.com/frgomes/mobile.g8/tree/expo-support
In this code
... I've got the error message below:
In the Expo documentation, they suggest that custom fonts should be installed more or less like below:
However, I'm reluctant to go thru this path without first understanding whether or not there's a better way of installing custom fonts using Sri.