question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.0.5) in React Native Expo

See original GitHub issue

Here is my code being used for testing. It works in a small node program but will not work in React Native.

import "@ethersproject/shims";
import { ethers } from "ethers";

const NodeAddress = "http://34.87.222.10:8545";
// ....
  useEffect(() => {
    (async () => {
      try {
        let p = await ethers.providers.getDefaultProvider(NodeAddress);
        await p._networkPromise;
        console.log(p);
      } catch (e) {
        console.log(e);
      }
    })();
  }, []);

// ....

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:22 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
nikita-zot-1408commented, Mar 2, 2021

Strangely,react native does not work with the current version of ethers library but it works fine with ethers version 5.0.5 and lower

1reaction
ricmoocommented, Feb 26, 2021

I think there may be. Depending on your setup (again, if you are using a proxy, things might further be affected), but you might want to adjust the network device to be any (I think you do this by specifying 0.0.0.0) and you might need to add the CORS origin flag to allow any (I don’t know the key or value to set for this).

If it is using CORS, make sure your Proxy is set up to forward OPTIONS too.

Setting up a link is definitely non-trivial…

Read more comments on GitHub >

github_iconTop Results From Across the Web

could not detect network (event="noNetwork", code ... - GitHub
Here is my code being used for testing. It works in a small node program but will not work in React Native. import...
Read more >
Error: could not detect network (event="noNetwork", code ...
I want to connect to ganache and I get ...
Read more >
error: could not detect network (event=nonetwork, code ...
I'm running a test contract on ETH. I Run :npx hardhat run scripts/deploy.js --network goerli. it ...
Read more >
NetInfo - React Native
Detect if the current active connection is metered or not. A network is classified as metered when the user is sensitive to heavy...
Read more >
@react-native-community/netinfo - npm
React Native Network Info API for iOS & Android. Latest version: 9.3.7, last published: a month ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found