From 372b4fa757d002a64581b1c24e786bde85f18ed6 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 15 Mar 2022 17:21:47 -0400 Subject: [PATCH 1/4] Update DevTools READMEs --- packages/react-devtools-core/README.md | 39 ++++--- packages/react-devtools-inline/README.md | 123 ++++++++++++++++++++--- packages/react-devtools-shared/README.md | 6 ++ packages/react-devtools/OVERVIEW.md | 12 ++- packages/react-devtools/README.md | 4 +- 5 files changed, 150 insertions(+), 34 deletions(-) create mode 100644 packages/react-devtools-shared/README.md diff --git a/packages/react-devtools-core/README.md b/packages/react-devtools-core/README.md index d139bf2e3b9..05b754a270f 100644 --- a/packages/react-devtools-core/README.md +++ b/packages/react-devtools-core/README.md @@ -29,33 +29,40 @@ The `config` object may contain: ## `react-devtools-core/standalone` -Renders the DevTools interface into a DOM node. - +Renders DevTools UI into a DOM node: ```js -require("react-devtools-core/standalone") - .setContentDOMNode(document.getElementById("container")) - .setStatusListener(status => { - // This callback is optional... - }) - .startServer(port); -``` +import DevtoolsUI from "react-devtools-core/standalone"; -Renders DevTools interface into a DOM node over SSL using a custom host name (Default is localhost). +const { setContentDOMNode, setStatusListener, startServer } = DevtoolsUI; +const container = document.getElementById("container"); + +setContentDOMNode(container); +setStatusListener(status => { + // This callback is optional... +}); +startServer(port, host, options); +``` + +Configures DevTools UI to use SSL with custom host name: ```js +import DevtoolsUI from "react-devtools-core/standalone"; + +const { setContentDOMNode, setStatusListener, startServer } = DevtoolsUI; + 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') }; +const container = document.getElementById("container"); -require("react-devtools-core/standalone") - .setContentDOMNode(document.getElementById("container")) - .setStatusListener(status => { - // This callback is optional... - }) - .startServer(port, host, options); +setContentDOMNode(container); +setStatusListener(status => { + // This callback is optional... +}); +startServer(port, host, options); ``` Reference the `react-devtools` package for a complete integration example. diff --git a/packages/react-devtools-inline/README.md b/packages/react-devtools-inline/README.md index 53edee429bd..0dcadbbcd39 100644 --- a/packages/react-devtools-inline/README.md +++ b/packages/react-devtools-inline/README.md @@ -4,7 +4,11 @@ React DevTools implementation for embedding within a browser-based IDE (e.g. [Co This is a low-level package. If you're looking for the standalone DevTools app, **use the `react-devtools` package instead.** -## Usage +--- + +**Note** that this package (and the DevTools UI) relies on several _experimental_ APIs that are only available in the [experimental release channel](https://reactjs.org/docs/release-channels.html#experimental-channel). + +# Usage This package exports two entry points: a frontend (to be run in the main `window`) and a backend (to be installed and run within an `iframe`1). @@ -16,9 +20,9 @@ The frontend and backend can be initialized in any order, but **the backend must 1 Sandboxed iframes are supported. -## API +# API -### `react-devtools-inline/backend` +## `react-devtools-inline/backend` * **`initialize(contentWindow)`** - Installs the global hook on the window. This hook is how React and DevTools communicate. **This method must be called before React is loaded.**2 @@ -43,7 +47,7 @@ activate(contentWindow); 2 The backend must be initialized before React is loaded. (This means before any `import` or `require` statements or `