gpt4 book ai didi

javascript - Property description must be an object 红屏错误 on new react-native app

转载 作者:行者123 更新时间:2023-11-30 06:14:35 25 4
gpt4 key购买 nike

我已经初始化了一个新的 react-native 应用程序,但即使没有对代码进行任何更改,我仍然收到以下红屏错误。

Java 版本 - 8节点 - 10.15.3 react native - 0.57.3

由于在较新版本中遇到很多错误,我已使用较低版本的 react-native 进行初始化。我是 native react 的新手。请帮忙。

App.js 文件。

/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';

const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});

export default class App extends Component{
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Text style={styles.instructions}>To get started, edit App.js</Text>
<Text style={styles.instructions}>{instructions}</Text>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});

索引.js

/** @format */

import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

包.json

{
"name": "GoSurf",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.6.0-alpha.8af6728",
"react-native": "0.57.3"
},
"devDependencies": {
"babel-jest": "24.8.0",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.55.0",
"react-test-renderer": "16.6.0-alpha.8af6728"
},
"jest": {
"preset": "react-native"
}
}

错误显示:-

https://drive.google.com/file/d/1-erzk1O-mZy6q-EuFBjE3qjhPgqmaMNA/view?usp=sharing

最佳答案

从发布的代码来看,我猜它与这一行有关:

<Text style={styles.instructions}>{instructions}</Text>

instructions 是一个对象而不是一个字符串

关于javascript - Property description must be an object 红屏错误 on new react-native app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56958587/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com