You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/react-devtools-inline/README.md
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,24 +21,32 @@ The frontend and backend can be initialized in any order, but **the backend must
21
21
### `react-devtools-inline/backend`
22
22
23
23
***`initialize(contentWindow)`** -
24
-
Installs the global hook on the window. This hook is how React and DevTools communicate. **This method must be called before React is loaded.** (This means before any `import` or `require` statements!)
24
+
Installs the global hook on the window. This hook is how React and DevTools communicate. **This method must be called before React is loaded.**<sup>2</sup>
25
25
***`activate(contentWindow)`** -
26
26
Lets the backend know when the frontend is ready. It should not be called until after the frontend has been initialized, else the frontend might miss important tree-initialization events.
// This should be the iframe the React application is running in.
32
+
constiframe=document.getElementById(frameID);
33
+
constcontentWindow=iframe.contentWindow;
34
+
31
35
// Call this before importing React (or any other packages that might import React).
32
-
initialize();
36
+
initialize(contentWindow);
37
+
38
+
// Initialize the frontend...
33
39
34
40
// Call this only once the frontend has been initialized.
35
-
activate();
41
+
activate(contentWindow);
36
42
```
37
43
44
+
<sup>2</sup> The backend must be initialized before React is loaded. (This means before any `import` or `require` statements or `<script>` tags that include React.)
45
+
38
46
### `react-devtools-inline/frontend`
39
47
40
48
***`initialize(contentWindow)`** -
41
-
Configures the DevTools interface to listen to the `window` the backend was injected into. This method returns a React component that can be rendered directly<sup>2</sup>.
49
+
Configures the DevTools interface to listen to the `window` the backend was injected into. This method returns a React component that can be rendered directly<sup>3</sup>.
<sup>2</sup> Because the DevTools interface makes use of several new React APIs (e.g. suspense, concurrent mode) it should be rendered using either `ReactDOM.unstable_createRoot` or `ReactDOM.unstable_createSyncRoot`. It should not be rendered with `ReactDOM.render`.
63
+
<sup>3</sup> Because the DevTools interface makes use of several new React APIs (e.g. suspense, concurrent mode) it should be rendered using either `ReactDOM.unstable_createRoot` or `ReactDOM.unstable_createSyncRoot`. **It should not be rendered with `ReactDOM.render`.**
56
64
57
65
## Examples
58
66
@@ -143,4 +151,11 @@ iframe.onload = () => {
143
151
"*"
144
152
);
145
153
};
154
+
```
155
+
156
+
## Development
157
+
158
+
Watch for changes made to the source code and rebuild:
Install the `react-devtools` package. Because this is a development tool, a global install is often the most convenient:
@@ -47,7 +47,8 @@ You can open the [in-app developer menu](https://facebook.github.io/react-native
47
47
48
48
However, when `react-devtools` is running, Inspector will enter a special collapsed mode, and instead use the DevTools as primary UI. In this mode, clicking on something in the simulator will bring up the relevant components in the DevTools:
You can choose "Hide Inspector" in the same menu to exit this mode.
53
54
@@ -61,7 +62,7 @@ Make sure that the dropdown in the top left corner of the Chrome console says `d
61
62
62
63
Then select a React component in React DevTools. There is a search box at the top that helps you find one by name. As soon as you select it, it will be available as `$r` in the Chrome console, letting you inspect its props, state, and instance properties.
@@ -90,7 +91,7 @@ This will ensure the developer tools are connected. **Don’t forget to remove i
90
91
91
92
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.
92
93
93
-
## Developing
94
+
## Development
94
95
95
96
* Run `yarn start:backend` and `yarn start:standalone` in `../react-devtools-core`
0 commit comments