admin管理员组

文章数量:1295295

I'm trying to install the standalone react-devtools, which by default listens to port 8097. My app uses port 3001. The documentation says the following:

"By default DevTools listen to port 8097 on localhost. If you need to customize host, port, or other settings, see the react-devtools-core package instead."

How do I go about changing the port to listen to 3001 instead?

Source:

I'm trying to install the standalone react-devtools, which by default listens to port 8097. My app uses port 3001. The documentation says the following:

"By default DevTools listen to port 8097 on localhost. If you need to customize host, port, or other settings, see the react-devtools-core package instead."

How do I go about changing the port to listen to 3001 instead?

Source: https://github./facebook/react-devtools/tree/master/packages/react-devtools

Share Improve this question edited Jul 9, 2017 at 1:39 Paul Roub 36.5k27 gold badges86 silver badges95 bronze badges asked Mar 28, 2017 at 16:12 a7dca7dc 3,4268 gold badges37 silver badges57 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

The docs advise to have a look at react-devtools-core:

require('react-devtools-core').connectToDevTools(options)

This is similar to require('react-devtools') in another package but providing more control. Unlike require('react-devtools'), it doesn't connect immediately, but exports a function.

Run connectToDevTools() in the same context as React to set up a connection to DevTools. Make sure this runs before any react, react-dom, or react-native imports.

The options object may contain:

  • host (string), defaults to 'localhost'.
  • port (number), defaults to 8097.
  • resolveRNStyle (function), used by RN and null by default.

You can also change your emulator or device port to 8097. Worked for me.

Eg: adb -s <device-name> reverse tcp:8097 tcp:8097

How to find device name: run adb devices

本文标签: