react/packages/react-devtools-core
Brian Vaughn a8de69f358
DevTools: Drop IE 11 support (#19875)
DevTools shared Babel config previously supported IE 11 to target Hermes (for the standalone backend that gets embedded within React Native apps). This targeting resulted in less optimal code for other DevTools targets though which did not need to support IE 11. This PR updates the shared config to remove IE 11 support by default, and only enables it for the standalone backend target.
2020-09-21 11:07:45 -04:00
..
src Add SSL support to React devtools standalone (#19191) 2020-07-06 10:09:41 -04:00
backend.js Standalone NPM packages and React Native support (#335) 2019-07-13 10:05:04 -07:00
package.json DevTools 4.8.1 -> 4.8.2 (and CHANGELOG) 2020-07-15 12:37:08 -04:00
README.md Add SSL support to React devtools standalone (#19191) 2020-07-06 10:09:41 -04:00
standalone.js Standalone NPM packages and React Native support (#335) 2019-07-13 10:05:04 -07:00
webpack.backend.js DevTools: Drop IE 11 support (#19875) 2020-09-21 11:07:45 -04:00
webpack.standalone.js Enable source maps for DevTools production builds (#19773) 2020-09-18 10:07:22 -04:00

react-devtools-core

A standalone React DevTools implementation.

This is a low-level package. If you're looking for the Electron app you can run, use react-devtools package instead.

API

react-devtools-core

This is similar requiring the react-devtools package, but provides several configurable options. Unlike react-devtools, requiring react-devtools-core doesn't connect immediately but instead exports a function:

const { connectToDevTools } = require("react-devtools-core");
connectToDevTools(config);

Run connectToDevTools() in the same context as React to set up a connection to DevTools.
Be sure to run this function before importing e.g. react, react-dom, react-native.

The config object may contain:

  • host: string (defaults to "localhost") - Websocket will connect to this host.
  • port: number (defaults to 8097) - Websocket will connect to this port.
  • useHttps: boolean (defaults to false) - Websocked should use a secure protocol (wss).
  • websocket: Websocket - Custom websocket to use. Overrides host and port settings if provided.
  • resolveRNStyle: (style: number) => ?Object - Used by the React Native style plug-in.
  • isAppActive: () => boolean - If provided, DevTools will poll this method and wait until it returns true before connecting to React.

react-devtools-core/standalone

Renders the DevTools interface into a DOM node.

require("react-devtools-core/standalone")
  .setContentDOMNode(document.getElementById("container"))
  .setStatusListener(status => {
    // This callback is optional...
  })
  .startServer(port);

Renders DevTools interface into a DOM node over SSL using a custom host name (Default is localhost).

const host = 'dev.server.com';
const options = {
  key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};


require("react-devtools-core/standalone")
  .setContentDOMNode(document.getElementById("container"))
  .setStatusListener(status => {
    // This callback is optional...
  })
  .startServer(port, host, options);

Reference the react-devtools package for a complete integration example.

Development

Watch for changes made to the backend entry point and rebuild:

yarn start:backend

Watch for changes made to the standalone UI entry point and rebuild:

yarn start:standalone