反应本地静态服务器错误:评估FPStaticServer.stop()

时间:2018-10-23 12:37:29

标签: android react-native react-native-android

当我运行react-native run-android时,我的模拟器显示此错误:

enter image description here

我想运行react-native-static-server以使用Webview在我的应用程序中离线显示react-vr导览。

这是我已构建项目的命令:

react-native init serverApp

cd serverApp

npm install react-native-static-server --save

react-native run-android

我已使用以下代码编辑App.js:

import StaticServer from 'react-native-static-server';

let server = new StaticServer(8080);

// Start the server
server.start().then((url) => {
  console.log("Serving at URL", url);
});

server.stop();

App.js:

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

import StaticServer from 'react-native-static-server';

let server = new StaticServer(8080);

// Start the server
server.start().then((url) => {
  console.log("Serving at URL", url);
});

server.stop();

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

问题:

我如何使用react-native-static-server运行本地服务器?

我如何解决此错误?

0 个答案:

没有答案