react-native-static-server icon indicating copy to clipboard operation
react-native-static-server copied to clipboard

Exception in native call from js

Open rishikeshwovvtech opened this issue 3 years ago • 3 comments

Im getting following error not able to proceed further

Screenshot 2021-12-28 at 2 32 40 PM

Here is my code

  import React, { useRef, useState, useEffect } from 'react';
  import { View, Text } from 'react-native';
  import StaticServer from 'react-native-static-server';
  const serverConfig = { localOnly: true, keepAlive: true };
  const App = () => {
    useEffect(() => {
       let server = new StaticServer(8080);
      // Start the server
      server.start().then((url) => {
        console.log("Serving at URL", url);
      });
   }, []);

  return (
    <View style={{ flex: 1, backgroundColor: 'red' }}>
    </View>
  )
}
export default App;

package.json

"dependencies": { "react": "16.8.1", "react-native": "0.61.3", "react-native-static-server": "^0.5.0" },

rishikeshwovvtech avatar Dec 28 '21 09:12 rishikeshwovvtech

Same here

freddygarcia avatar Jan 19 '22 22:01 freddygarcia

Take your server instantiation out of useEffect, you're using the hook improperly.

stockhuman avatar Mar 09 '22 20:03 stockhuman

I got the same error. I solved it by entering the path value.

new StaticServer(8080, RNFS.DocumentDirectoryPath); // <- added path

It worked for me.

yasintorun avatar Jul 29 '22 13:07 yasintorun