我今天在我的react native / expo项目中遇到了这个错误。我尝试清除缓存并重新安装软件包等。
我的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": {
"@firebase/app": "^0.3.4",
"babel": "^6.23.0",
"babel-plugin-module-resolver": "^3.1.1",
"babel-preset-env": "^1.7.0",
"babel-preset-expo": "^5.0.0",
"eslint": "^5.8.0",
"expo": "^31.0.0",
"expo-cli": "^2.2.5",
"firebase": "^5.5.7",
"for": "^0.1.0",
"lodash": "^4.17.11",
"me": "^0.3.0",
"moment": "^2.22.2",
"react": "^16.6.0",
"react-native": "^0.57.4",
"react-native-blur": "^3.2.2",
"react-native-elements": "^0.19.1",
"react-native-keyboard-aware-scrollview": "^2.0.0",
"react-native-material-textfield": "^0.12.0",
"react-native-platform-touchable": "^1.1.1",
"react-native-scrollable-tab-view": "^0.9.0",
"react-native-snap-carousel": "^3.7.5",
"react-native-swiper": "^1.5.13",
"react-native-tab-view": "^1.2.0",
"react-native-vector-icons": "^6.0.2",
"react-navigation": "^2.18.2",
"react-redux": "^5.1.0",
"redux-persist": "^5.10.0",
"redux-thunk": "^2.3.0",
"windows": "0.0.8",
"worked": "^0.0.2",
"ws": "^6.1.0"
},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"babel-core": "^7.0.0-bridge.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-react": "^6.24.1",
"redux": "^4.0.1",
"remote-redux-devtools": "^0.5.13"
},
"resolutions": {
"babel-core": "7.0.0-bridge.0"
}
}
我的字体系列用例类似于以下内容:
export default StyleSheet.create({
container: {
borderRadius: 4,
borderWidth: 0.5,
borderColor: '#d6d7da',
},
title: {
textAlign: 'center',
fontSize: 30,
marginBottom: 0,
fontFamily: 'mainFontBold',
},
其中mainFontBold是在我的app.js中加载的自定义字体。在今天之前,这种方法一直运行良好,我不确定导致此更改的原因是什么。
我不知道为什么会给我这个错误?博览会文档明确指出fontFamily是文本的有效样式属性,请参阅:
https://facebook.github.io/react-native/docs/text-style-props#fontfamily
有人知道我如何能够解决此问题,或者是什么导致了此错误吗?谢谢!
答案 0 :(得分:2)
修改package.json后,我遇到了同样的问题。 我所做的修改是从以下更改:
dependencies: {
...,
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
}
收件人:
dependencies: {
...,
"react-native": "0.57.4",
}
我不确定,但似乎expo使用的是特定的本机版本。 有关此主题的更多文档,请访问:https://docs.expo.io/versions/v31.0.0/workflow/upgrading-expo-sdk-walkthrough
答案 1 :(得分:0)