无法识别的字体家族“ entypo”

时间:2018-08-31 05:42:10

标签: react-native react-navigation expo create-react-native-app

我正在使用博览会团队的create react native应用程序来构建应用程序。使用react-native-elements中的Icon组件创建react导航标题功能。下面的代码段:

const Navigator = new createStackNavigator({
  Home: {
    screen: Home,
    path: '/',
    navigationOptions: ({ navigation }) => ({
      title: 'Home',
      headerStyle: {
        backgroundColor: 'black'
      },
      headerLeft: (
        <Icon
          name="menu"
          size={30}
          type="entypo"
          style={{ paddingLeft: 10 }}
        />
      ),
    }),
  },
})

我遇到此错误: Unrecognised font family error message

经过无数次迭代,我发现博览会团队在1st2nd周围进行了这项工作,并在下面为该应用实现了此目的,但仍然遇到相同的问题。

import Expo from "expo";
import React from 'react';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
import { AppLoading, Asset, Font } from 'expo';
import { FontAwesome, Ionicons } from '@expo/vector-icons';
import { connect } from 'react-redux'
import { Auth } from 'aws-amplify';
import AuthTabs from './auth/Tabs';
import Nav from './navs/Navigator';
import Home from "./components/Home";


class App extends React.Component {
  state = {
    user: {},
    isLoading: true,
    isLoadingComplete: false,
  };


  async componentDidMount() {
    StatusBar.setHidden(true)
    try {
      const user = await Auth.currentAuthenticatedUser()
      this.setState({ user, isLoading: false })
    } catch (err) {
      this.setState({ isLoading: false })
    }
  }

  async componentWillReceiveProps(nextProps) {
    try {
      const user = await Auth.currentAuthenticatedUser()
      this.setState({ user })
    } catch (err) {
      this.setState({ user: {} })
    }
  }


  render() {
      if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {

        return(
          <AppLoading
            startAsync={this._loadResourcesAsync}
            onError={this._handleLoadingError}
            onFinish={this._handleFinishLoading}
          />
      );
      }

      else{
        if (this.state.isLoading) return null

        let loggedIn = false
        if (this.state.user.username) {
          loggedIn = true
        }

        if (loggedIn) {
          return (
            <Nav />
          )
        }
        return (
          <AuthTabs />
        )

}

}


_loadResourcesAsync = async () => {

  console.log("fonts loading..")

  const entypoFont = {
    'entypo': require('../node_modules/@expo/vector-icons/fonts/Entypo.ttf')
  };
  const fontAssets = cacheFonts([ FontAwesome.font, Ionicons.font, entypoFont ]);
   console.log("loaded all fonts locally")
  await Promise.all([...fontAssets]);

  console.log("promisified all fonts")

  };

  _handleLoadingError = error => {
    console.warn(error);
  };

  _handleFinishLoading = () => {
    this.setState({ isLoadingComplete: true });
  };
}

function cacheFonts(fonts){
  return fonts.map(font => Font.loadAsync(font))
}

const mapStateToProps = state => ({
  auth: state.auth
})

export default connect(mapStateToProps)(App)

我在做什么错,如何正确配置?谢谢

0 个答案:

没有答案