使用矢量图标时的EXPO错误和警告

时间:2019-06-04 06:46:01

标签: react-native expo

我最近将Expo SDK从3.0更新到了3.2,我突然开始遇到各种错误,起初我需要替换

中的矢量图标

import Icon from "react-native-vector-icons/Ionicons";

import {Ionicons} from '@expo/vector-icons';

因为我开始使用旧方法出现以下错误 fontFamily "Ionicons" is not a system font and has not been loaded through Font.loadAsync.

我检查了博览会文档https://docs.expo.io/versions/latest/guides/icons/

这是推荐方法。但是现在使用此方法时,我收到以下消息

The syntax "import { Font } from 'expo-font'" is deprecated. Use "import * as Font from 'expo-font'" or import named exports instead. Support for the old syntax will be removed in SDK 33.

所以我很困惑,因为建议在3.2版中使用此方法,但在下一个版本中也会弃用该方法

我尝试更改.babelrc文件

{ 
    "presets": [ "babel-preset-expo" ] 
}
// Uitgeschakeld inverband met https://github.com/expo/expo/issues/2576
// {
//   "presets": ["babel-preset-expo"],
//   "env": {
//     "development": {
//       "plugins": ["transform-react-jsx-source"]
//     }
//   }
// }

删除node_modules并重新安装

检查app.json和package.json中的博览会版本

App.json

{
  "expo": {
    "name": "Rapio",
    "description": "Wait less, enjoy more.",
    "slug": "Rapio",
    "privacy": "public",
    "sdkVersion": "32.0.0",
    "ios": {
      "bundleIdentifier": "com.rapio.consumerapp"
    },
    "android": {
      "package": "com.rapio.consumerapp"
    },
    "platforms": ["ios", "android"],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    }
  }
}

package.json

{
  "name": "empty-project-template",
  "main": "node_modules/expo/AppEntry.js",
  "private": true,
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo/vector-icons": "^8.0.0",
    "axios": "^0.18.0",
    "expo": "^32.0.0",
    "navigation": "^5.1.0",
    "react": "^16.6.0",
    "react-native": "0.57.1",
    "react-native-elements": "^1.1.0",
    "react-native-fbsdk": "^0.8.0",
    "react-native-maps": "^0.22.1",
    "react-native-payment-gateway": "^0.4.3",
    "react-native-simple-radio-button": "^2.7.3",
    "react-native-vector-icons": "^6.4.2",
    "react-navigation": "^2.18.2",
    "react-redux": "^5.1.1",
    "redux": "^4.0.1"
  },
  "devDependencies": {
    "schedule": "^0.4.0"
  }
}

我希望能够使用正确的图标使用方法,而不会收到错误消息或警告

0 个答案:

没有答案