where is the path of my react native static server

26
January 11, 2019, at 8:20 PM

I'm trying to run a static server in my app developed with react native, with the packages react-native-static-server and react-native-fs.

but I can not find the folder in which I have to insert the html, js and css files.

so I would like to know that url I have to insert in a WebView with an output like the one in the image shown below.

this is a screenshot of a test app that shows the local url and the folder in which to place the files:

App.js

import React, {Component} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import StaticServer from 'react-native-static-server';
import RNFS from 'react-native-fs';
export default class App extends Component<Props> {
  constructor(props) {
    super(props);
    this.state = {
      indirizzo: '',
      path:''
    };
  }
  componentDidMount(){
    let path = RNFS.DocumentDirectoryPath + '/www';
    let server = new StaticServer(8080, path);
    server.start().then((url) => {
      console.log("Serving at URL", url);
      this.setState({
        indirizzo:url,
        path:path
      });
    });
  }
  componentWillUnmount(){
    server.stop();
  }
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.instructions}>url: {this.state.indirizzo}</Text>
        <Text style={styles.instructions}>path: {this.state.path}</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,
  },
});

package.json

{
  "name": "testServerApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.6.3",
    "react-native": "0.57.8",
    "react-native-fs": "^2.13.3",
    "react-native-static-server": "^0.4.0"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.51.1",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

thank you ;)

READ ALSO
Read/write ble characteristics from/to particular service

Read/write ble characteristics from/to particular service

I have several services with different UUIDs, but with the same characteristics UUIDsI'm not sure what characteristic will be got if I call rxBleConnection

36
Updating ExpandableListView inside a fragment from another Activity (not the parent Activity)

Updating ExpandableListView inside a fragment from another Activity (not the parent Activity)

In my case i have two Activities that contains a ViewPager with the relative FragmentsSo the situation is something like that:

41
Haven&#39;t perfect understanding with Firebase-Database and Firebase-authentication

Haven't perfect understanding with Firebase-Database and Firebase-authentication

In hear I'm supposed to register users from my web appBut after one user registration, the second user always removes current user details and come under the previous uid

52