首页 > 解决方案 > 开发服务器返回响应错误代码:500 - ReactNative

问题描述

我收到错误消息-

The development server returned response error code: 500,

尝试使用运行 React Native 代码时

react-native run-android.

在此处输入图像描述

我不知道如何解决这个错误(截图中的那个)。虽然,我试过 -

请指导我摆脱这个错误的永久修复。

我使用的代码是 -

import React, {
    Component,
DrawerLayoutAndroid
} from 'react';

import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Button,
    Dimensions
} from 'react-native';

import {
    StackNavigator
} from 'react-navigation';


class MainActivity extends Component {

    static navigationOptions = {
        title: 'MainActivity',
    };

    FunctionToOpenSecondActivity = () => {
        this.props.navigation.navigate('Second');

    }

    render() {
        return ( <
            View style = {
                styles.MainContainer
            } >

            <
            View style = {
                {
                    marginBottom: 20
                }
            } >

            <
            Text style = {
                styles.TextStyle
            } > This is MainActivity < /Text>

            <
            /View>

            <
            Button onPress = {
                this.FunctionToOpenSecondActivity
            }
            title = 'Click here To Open Second Activity' / >
            </View>
        );
    }
}

class SecondActivity extends Component {
    static navigationOptions = {
        title: 'SecondActivity',
    };

    render() {

      var navigationView = (
        <View style = {{flex: 1, backgroundColor: '#fff'}}>
        <Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>I am in the Drawer</Text>
        </View>

        );
var DrawerLayoutAndroid = require('DrawerLayoutAndroid');
        return ( <
            View style = {
                styles.MainContainer
            } >


            <DrawerLayoutAndroid
                 drawerWidth={100}
                 drawerPosition={DrawerLayoutAndroid.positions.Left}

                 renderNavigationView={() => navigationView}>
                 <View style={{flex: 1, alignItems: 'center'}}>
                   <Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>Hello</Text>
                   <Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>World!</Text>
                 </View>
               </DrawerLayoutAndroid>
            <
            /View>


        );
    }
}

export default Project = StackNavigator({
    First: {
        screen: MainActivity
    },

    Second: {
        screen: SecondActivity
    }
});

const styles = StyleSheet.create({
    MainContainer: {
        justifyContent: 'center',
        flex: 1,
        margin: 10

    },

    TextStyle: {
        fontSize: 23,
        textAlign: 'center',
        color: '#000',
    },

});

const FirstRoute = () => (
  <View style={[styles.container, { backgroundColor: '#ff4081' }]} />
);
const SecondRoute = () => (
  <View style={[styles.container, { backgroundColor: '#673ab7' }]} />
);

我曾尝试检查类似的问题,但无法获得任何令人满意的结果。

标签: androidreact-native

解决方案


推荐阅读