Skip to content

Commit 21a851e

Browse files
alexandrutasicakassens
authored andcommitted
Fix devtools typos and grammar (#24587)
Closes #24587
1 parent cfafeb6 commit 21a851e

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

packages/react-client/src/__tests__/ReactFlight-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ describe('ReactFlight', () => {
705705
});
706706

707707
// @gate enableServerContext
708-
it('propagates ServerContext and cleansup providers in flight', async () => {
708+
it('propagates ServerContext and cleans up the providers in flight', async () => {
709709
const ServerContext = React.createServerContext(
710710
'ServerContext',
711711
'default',
@@ -856,7 +856,7 @@ describe('ReactFlight', () => {
856856
});
857857

858858
// @gate enableServerContext
859-
it('takes ServerContext from client for refetching usecases', async () => {
859+
it('takes ServerContext from the client for refetching use cases', async () => {
860860
const ServerContext = React.createServerContext(
861861
'ServerContext',
862862
'default',

packages/react-devtools-core/src/editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function guessEditor(): Array<string> {
9797
}
9898
}
9999

100-
// Last resort, use old skool env vars
100+
// Last resort, use old-school env vars
101101
if (process.env.VISUAL) {
102102
return [process.env.VISUAL];
103103
} else if (process.env.EDITOR) {

packages/react-devtools/OVERVIEW.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The React DevTools extension consists of multiple pieces:
44
* The **frontend** portion is the extension you see (the Components tree, the Profiler, etc.).
55
* The **backend** portion is invisible. It runs in the same context as React itself. When React commits changes to e.g. the DOM, the backend is responsible for notifying the frontend by sending a message through the **bridge** (an abstraction around e.g. `postMessage`).
66

7-
One of the largest performance bottlenecks of the old React DevTools was the amount of bridge traffic. Each time React commits an update, the backend sends every fiber that changed across the bridge, resulting in a lot of (JSON) serialization. The primary goal for the DevTools rewrite was to reduce this traffic. Instead of sending everything across the bridge, **the backend should only send the minimum amount required to render the Components tree**. The frontend can request more information (e.g. an element's props) on demand, only as needed.
7+
One of the largest performance bottlenecks of the old React DevTools was the amount of bridge traffic. Each time React commits an update, the backend sends every fiber that changed across the bridge, resulting in a lot of (JSON) serialization. The primary goal for the DevTools rewrite was to reduce this traffic. Instead of sending everything across the bridge, **the backend should only send the minimum amount required to render the Components tree**. The frontend can request more information (e.g. an element's props) on-demand, only as needed.
88

99
The old DevTools also rendered the entire application tree in the form of a large DOM structure of nested nodes. A secondary goal of the rewrite was to avoid rendering unnecessary nodes by using a windowing library (specifically [react-window](https://github.com/bvaughn/react-window)).
1010

@@ -24,7 +24,7 @@ The string table is encoded right after the first two numbers.
2424

2525
It consists of:
2626

27-
1. the total length of next items that belong to string table
27+
1. the total length of the next items that belong to the string table
2828
2. for each string in a table:
2929
* encoded size
3030
* a list of its UTF encoded codepoints
@@ -136,7 +136,7 @@ For example:
136136

137137
#### Updating tree base duration
138138

139-
While profiling is in progress, we send an extra operation any time a fiber is added or a updated in a way that affects its tree base duration. This information is needed by the Profiler UI in order to render the "snapshot" and "ranked" chart views.
139+
While profiling is in progress, we send an extra operation any time a fiber is added or updated in a way that affects its tree base duration. This information is needed by the Profiler UI in order to render the "snapshot" and "ranked" chart views.
140140

141141
1. tree base duration constant (`4`)
142142
1. fiber id
@@ -170,7 +170,7 @@ We only send the serialized messages as part of the `inspectElement` event.
170170

171171
#### Removing a root
172172

173-
Special case of unmounting an entire root (include its descendants). This specialized message replaces what would otherwise be a series of remove-node operations. It is currently only used in one case: updating component filters. The primary motivation for this is actually to preserve fiber ids for components that are re-added to the tree after the updated filters have been applied. This preserves mappings between the Fiber (id) and things like error and warning logs.
173+
A special case of unmounting an entire root (including its descendants). This specialized message replaces what would otherwise be a series of remove-node operations. It is currently only used in one case: updating component filters. The primary motivation for this is actually to preserve fiber ids for components that are re-added to the tree after the updated filters have been applied. This preserves mappings between the Fiber (id) and things like error and warning logs.
174174

175175
```js
176176
[
@@ -210,7 +210,7 @@ The frontend stores its information about the tree in a map of id to objects wit
210210

211211
<sup>1</sup> The `depth` value determines how much padding/indentation to use for the element when rendering it in the Components panel. (This preserves the appearance of a nested tree, even though the view is a flat list.)
212212

213-
<sup>2</sup> The `weight` of an element is the number of elements (including itself) below it in the tree. We cache this property so that we can quickly determine the total number of Components as well as to find the Nth element within that set. (This enables us to use windowing.) This value needs to be adjusted each time elements are added or removed from the tree, but we amortize this over time to avoid any big performance hits when rendering the tree.
213+
<sup>2</sup> The `weight` of an element is the number of elements (including itself) below it in the tree. We cache this property so that we can quickly determine the total number of Components as well as find the Nth element within that set. (This enables us to use windowing.) This value needs to be adjusted each time elements are added or removed from the tree, but we amortize this over time to avoid any big performance hits when rendering the tree.
214214

215215
#### Finding the element at index N
216216

@@ -263,21 +263,21 @@ while (index !== currentWeight) {
263263

264264
When an element is mounted in the tree, DevTools sends a minimal amount of information about it across the bridge. This information includes its display name, type, and key- but does _not_ include things like props or state. (These values are often expensive to serialize and change frequently, which would add a significant amount of load to the bridge.)
265265

266-
Instead DevTools lazily requests additional information about an element only when it is selected in the "Components" tab. At that point, the frontend requests this information by sending a special "_inspectElement_" message containing the id of the element being inspected. The backend then responds with an "_inspectedElement_" message containing the additional details.
266+
Instead, DevTools lazily requests additional information about an element only when it is selected in the "Components" tab. At that point, the frontend requests this information by sending a special "_inspectElement_" message containing the id of the element being inspected. The backend then responds with an "_inspectedElement_" message containing the additional details.
267267

268268
### Polling strategy
269269

270-
Elements can update frequently, especially in response to things like scrolling events. Since props and state can be large, we avoid sending this information across the bridge every time the selected element is updated. Instead, the frontend polls the backend for updates about once a second. The backend tracks when the element was last "inspected" and sends a special no-op response if it has not re-rendered since then.
270+
Elements can update frequently, especially in response to things like scrolling events. Since props and state can be large, we avoid sending this information across the bridge every time the selected element is updated. Instead, the frontend polls the backend for updates about once a second. The backend tracks when the element was last "inspected" and sends a special no-op response if it has not been re-rendered since then.
271271

272272
### Deeply nested properties
273273

274-
Even when dealing with a single component, serializing deeply nested properties can be expensive. Because of this, DevTools uses a technique referred to as "dehydration" to only send a shallow copy of the data on initial inspection. DevTools then fills in the missing data on demand as a user expands nested objects or arrays. Filled in paths are remembered (for the currently inspected element) so they are not "dehydrated" again as part of a polling update.
274+
Even when dealing with a single component, serializing deeply nested properties can be expensive. Because of this, DevTools uses a technique referred to as "dehydration" to only send a shallow copy of the data on initial inspection. DevTools then fills in the missing data on-demand as a user expands nested objects or arrays. Filled in paths are remembered (for the currently inspected element) so they are not "dehydrated" again as part of a polling update.
275275

276276
### Inspecting hooks
277277

278278
Hooks present a unique challenge for the DevTools because of the concept of _custom_ hooks. (A custom hook is essentially any function that calls at least one of the built-in hooks. By convention custom hooks also have names that begin with "use".)
279279

280-
So how does DevTools identify custom functions called from within third party components? It does this by temporarily overriding React's built-in hooks and shallow rendering the component in question. Whenever one of the (overridden) built-in hooks are called, it parses the call stack to spot potential custom hooks (functions between the component itself and the built-in hook). This approach enables it to build a tree structure describing all of the calls to both the built-in _and_ custom hooks, along with the values passed to those hooks. (If you're interested in learning more about this, [here is the source code](https://github.com/facebook/react/blob/main/packages/react-debug-tools/src/ReactDebugHooks.js).)
280+
So how does DevTools identify custom functions called from within third-party components? It does this by temporarily overriding React's built-in hooks and shallow rendering the component in question. Whenever one of the (overridden) built-in hooks are called, it parses the call stack to spot potential custom hooks (functions between the component itself and the built-in hook). This approach enables it to build a tree structure describing all of the calls to both the built-in _and_ custom hooks, along with the values passed to those hooks. (If you're interested in learning more about this, [here is the source code](https://github.com/facebook/react/blob/main/packages/react-debug-tools/src/ReactDebugHooks.js).)
281281

282282
> **Note**: DevTools obtains hooks info by re-rendering a component.
283283
> Breakpoints will be invoked during this additional (shallow) render,
@@ -289,7 +289,7 @@ To mitigate the performance impact of re-rendering a component, DevTools does th
289289
* Only function components that use _at least one hook_ are rendered. (Props and state can be analyzed without rendering.)
290290
* Rendering is always shallow.
291291
* Rendering is throttled to occur, at most, once per second.
292-
* Rendering is skipped if the component has not updated since the last time its properties were inspected.
292+
* Rendering is skipped if the component has been not updated since the last time its properties were inspected.
293293

294294
## Profiler
295295

@@ -308,7 +308,7 @@ When profiling begins, the backend records the base durations of each fiber curr
308308
* Which elements were rendered during that commit
309309
* Which props and state changed (if enabled in profiler settings)
310310

311-
This information will eventually be required by the frontend in order to render its profiling graphs, but it will not be sent across the bridge until profiling has completed (to minimize the performance impact of profiling).
311+
This information will eventually be required by the frontend in order to render its profiling graphs, but it will not be sent across the bridge until profiling has been completed (to minimize the performance impact of profiling).
312312

313313
### Timeline profiler
314314

@@ -318,7 +318,7 @@ Timeline profiling data can come from one of two places:
318318

319319
### Combining profiling data
320320

321-
Once profiling is finished, the frontend requests profiling data from the backend one renderer at a time by sending a "_getProfilingData_" message. The backend responds with a "_profilingData_" message that contains per-root commit timing and duration information. The frontend then combines this information with its own snapshots to form a complete picture of the profiling session. Using this data, charts and graphs are lazily computed (and incrementally cached) on demand, based on which commits and views are selected in the Profiler UI.
321+
Once profiling is finished, the frontend requests profiling data from the backend one renderer at a time by sending a "_getProfilingData_" message. The backend responds with a "_profilingData_" message that contains per-root commit timing and duration information. The frontend then combines this information with its own snapshots to form a complete picture of the profiling session. Using this data, charts and graphs are lazily computed (and incrementally cached) on-demand, based on which commits and views are selected in the Profiler UI.
322322

323323
### Importing/exporting data
324324

0 commit comments

Comments
 (0)