繁体   English   中英

属性描述必须是新的react-native应用上的对象红色屏幕错误

[英]Property description must be an object red screen error on new react-native app

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

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

我在较低版本的react-native中进行了初始化,因为在较新版本中遇到了许多错误。 我是本机反应的新手。 请帮忙。

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,
  },
});

index.js

/** @format */

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

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

的package.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 }不是对象-至少我们不能从该代码段中看出。 它只是说在JSX中告诉将<Text>节点内的instructions值注入

我们今天也遇到了这个问题。 原来,这是redux的最新更新。 恢复为redux@4.0.0 ,错误将消失

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM