错误代码:React Native 0.56 for Android上的500 [英] error code: 500 on react native 0.56 for android

查看:113
本文介绍了错误代码:React Native 0.56 for Android上的500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目是一个新的空反应本机项目. 一切在构建时都很酷,但是在android设备上,我每次都遇到红色的错误500"屏幕. 我已经尝试过以下代码:

my project is a new empty react native project. everything is cool at the time of build, but on android device I face the red "error 500" screen every time. I've tried this code:

yarn remove babel-preset-react-native
yarn add babel-preset-react-native@2.1.0

到目前为止没有任何改变!

no change so far!

我已尝试将本机的React降级为55.4-不变! 清洁渔获物-不变! 顺便说一下,这是我的App.js:

I've tried to downgrade the react native to 55.4 - no change! Cleaning the catch - no change! Here is my App.js by the way:

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

type Props = {};
export default class App extends Component<Props> {
  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:

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

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

这是我的package.json:

and here is my package.json:

{
  "name": "app",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.4.1",
    "react-native": "0.56.0"
  },
  "devDependencies": {
    "babel-jest": "23.4.2",
    "babel-preset-react-native": "5",
    "jest": "23.5.0",
    "react-test-renderer": "16.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Windows 10 64位 网络风暴

Windows 10 64bit Webstorm

推荐答案

最新的react native版本似乎存在一些问题.

There seems to be some issue with latest react native version.

使用以下命令创建项目.

Create the project with below command.

react-native init --version="0.54.0" ProjectName

它肯定会工作.

这篇关于错误代码:React Native 0.56 for Android上的500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆