Skip to content

Commit 843c1ba

Browse files
author
Brian Vaughn
committed
Fixed invalid DevTools work tags
Work tags changed recently (PR facebook#13902) but we didn't bump React versions. This meant that DevTools has valid work tags only for master (and FB www sync) but invalid work tags for the latest open source releases. To fix this, I incremneted React's version in Git (without an actual release) and added a new fork to the work tags detection branch. This commit also adds tags for the experimental Scope and Fundamental APIs to DevTools so component names will at least display correctly. Technically these new APIs were first introduced to experimental builds ~16.9 but I didn't add a new branch to the work tags fork because I don't they're used commonly. I've just added them to the 17+ branches.
1 parent 2cf8f7f commit 843c1ba

File tree

10 files changed

+84
-19
lines changed

10 files changed

+84
-19
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106
},
107107
"scripts": {
108108
"build": "node ./scripts/rollup/build.js",
109-
"build-for-devtools-dev": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react-dom/index,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh --type=NODE_DEV",
110-
"build-for-devtools-prod": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react-dom/index,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh --type=NODE_PROD",
109+
"build-for-devtools-dev": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react-dom,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh --type=NODE_DEV",
110+
"build-for-devtools-prod": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react-dom,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh --type=NODE_PROD",
111111
"linc": "node ./scripts/tasks/linc.js",
112112
"lint": "node ./scripts/tasks/eslint.js",
113113
"lint-build": "node ./scripts/rollup/validate/index.js",

packages/react-art/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-art",
33
"description": "React ART is a JavaScript library for drawing vector graphics using React. It provides declarative and reactive bindings to the ART library. Using the same declarative API you can render the output to either Canvas, SVG or VML (IE8).",
4-
"version": "17.0.1",
4+
"version": "17.0.2",
55
"main": "index.js",
66
"repository": {
77
"type": "git",
@@ -29,7 +29,7 @@
2929
"scheduler": "^0.20.1"
3030
},
3131
"peerDependencies": {
32-
"react": "17.0.1"
32+
"react": "17.0.2"
3333
},
3434
"files": [
3535
"LICENSE",

packages/react-devtools-shared/src/backend/renderer.js

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import {gte} from 'semver';
10+
import {gt, gte} from 'semver';
1111
import {
1212
ComponentFilterDisplayName,
1313
ComponentFilterElementType,
@@ -166,8 +166,10 @@ export function getInternalReactConstants(
166166
// **********************************************************
167167
// The section below is copied from files in React repo.
168168
// Keep it in sync, and add version guards if it changes.
169-
if (gte(version, '17.0.0-alpha')) {
170-
// TODO (Offscreen) Update the version number above to reflect the first Offscreen alpha/beta release.
169+
//
170+
// TODO Update the gt() check below to be gte() whichever the next version number is.
171+
// Currently the version in Git is 17.0.2 (but that version has not been/may not end up being released).
172+
if (gt(version, '17.0.1')) {
171173
ReactTypeOfWork = {
172174
ClassComponent: 1,
173175
ContextConsumer: 9,
@@ -178,17 +180,50 @@ export function getInternalReactConstants(
178180
ForwardRef: 11,
179181
Fragment: 7,
180182
FunctionComponent: 0,
183+
FundamentalComponent: 20, // Experimental
181184
HostComponent: 5,
182185
HostPortal: 4,
183186
HostRoot: 3,
184187
HostText: 6,
185188
IncompleteClassComponent: 17,
186189
IndeterminateComponent: 2,
187190
LazyComponent: 16,
191+
LegacyHiddenComponent: 23,
188192
MemoComponent: 14,
189193
Mode: 8,
190194
OffscreenComponent: 22, // Experimental
191195
Profiler: 12,
196+
ScopeComponent: 21, // Experimental
197+
SimpleMemoComponent: 15,
198+
SuspenseComponent: 13,
199+
SuspenseListComponent: 19, // Experimental
200+
YieldComponent: -1, // Removed
201+
};
202+
} else if (gte(version, '17.0.0-alpha')) {
203+
ReactTypeOfWork = {
204+
ClassComponent: 1,
205+
ContextConsumer: 9,
206+
ContextProvider: 10,
207+
CoroutineComponent: -1, // Removed
208+
CoroutineHandlerPhase: -1, // Removed
209+
DehydratedSuspenseComponent: 18, // Behind a flag
210+
ForwardRef: 11,
211+
Fragment: 7,
212+
FunctionComponent: 0,
213+
FundamentalComponent: 20, // Experimental
214+
HostComponent: 5,
215+
HostPortal: 4,
216+
HostRoot: 3,
217+
HostText: 6,
218+
IncompleteClassComponent: 17,
219+
IndeterminateComponent: 2,
220+
LazyComponent: 16,
221+
LegacyHiddenComponent: 24,
222+
MemoComponent: 14,
223+
Mode: 8,
224+
OffscreenComponent: 23, // Experimental
225+
Profiler: 12,
226+
ScopeComponent: 21, // Experimental
192227
SimpleMemoComponent: 15,
193228
SuspenseComponent: 13,
194229
SuspenseListComponent: 19, // Experimental
@@ -205,17 +240,20 @@ export function getInternalReactConstants(
205240
ForwardRef: 11,
206241
Fragment: 7,
207242
FunctionComponent: 0,
243+
FundamentalComponent: -1, // Experimental
208244
HostComponent: 5,
209245
HostPortal: 4,
210246
HostRoot: 3,
211247
HostText: 6,
212248
IncompleteClassComponent: 17,
213249
IndeterminateComponent: 2,
214250
LazyComponent: 16,
251+
LegacyHiddenComponent: -1,
215252
MemoComponent: 14,
216253
Mode: 8,
217254
OffscreenComponent: -1, // Experimental
218255
Profiler: 12,
256+
ScopeComponent: -1, // Experimental
219257
SimpleMemoComponent: 15,
220258
SuspenseComponent: 13,
221259
SuspenseListComponent: 19, // Experimental
@@ -232,17 +270,20 @@ export function getInternalReactConstants(
232270
ForwardRef: 13,
233271
Fragment: 9,
234272
FunctionComponent: 0,
273+
FundamentalComponent: -1, // Experimental
235274
HostComponent: 7,
236275
HostPortal: 6,
237276
HostRoot: 5,
238277
HostText: 8,
239278
IncompleteClassComponent: -1, // Doesn't exist yet
240279
IndeterminateComponent: 4,
241280
LazyComponent: -1, // Doesn't exist yet
281+
LegacyHiddenComponent: -1,
242282
MemoComponent: -1, // Doesn't exist yet
243283
Mode: 10,
244284
OffscreenComponent: -1, // Experimental
245285
Profiler: 15,
286+
ScopeComponent: -1, // Experimental
246287
SimpleMemoComponent: -1, // Doesn't exist yet
247288
SuspenseComponent: 16,
248289
SuspenseListComponent: -1, // Doesn't exist yet
@@ -259,17 +300,20 @@ export function getInternalReactConstants(
259300
ForwardRef: 14,
260301
Fragment: 10,
261302
FunctionComponent: 1,
303+
FundamentalComponent: -1, // Experimental
262304
HostComponent: 5,
263305
HostPortal: 4,
264306
HostRoot: 3,
265307
HostText: 6,
266308
IncompleteClassComponent: -1, // Doesn't exist yet
267309
IndeterminateComponent: 0,
268310
LazyComponent: -1, // Doesn't exist yet
311+
LegacyHiddenComponent: -1,
269312
MemoComponent: -1, // Doesn't exist yet
270313
Mode: 11,
271314
OffscreenComponent: -1, // Experimental
272315
Profiler: 15,
316+
ScopeComponent: -1, // Experimental
273317
SimpleMemoComponent: -1, // Doesn't exist yet
274318
SuspenseComponent: 16,
275319
SuspenseListComponent: -1, // Doesn't exist yet
@@ -301,7 +345,10 @@ export function getInternalReactConstants(
301345
HostPortal,
302346
HostText,
303347
Fragment,
348+
LazyComponent,
349+
LegacyHiddenComponent,
304350
MemoComponent,
351+
OffscreenComponent,
305352
SimpleMemoComponent,
306353
SuspenseComponent,
307354
SuspenseListComponent,
@@ -354,11 +401,17 @@ export function getInternalReactConstants(
354401
case HostText:
355402
case Fragment:
356403
return null;
404+
case LazyComponent:
405+
return 'Lazy';
357406
case MemoComponent:
358407
case SimpleMemoComponent:
359408
return getDisplayName(resolvedType, 'Anonymous');
360409
case SuspenseComponent:
361410
return 'Suspense';
411+
case LegacyHiddenComponent:
412+
return 'LegacyHidden';
413+
case OffscreenComponent:
414+
return 'Offscreen';
362415
case SuspenseListComponent:
363416
return 'SuspenseList';
364417
default:
@@ -493,10 +546,14 @@ export function attach(
493546

494547
const debug = (name: string, fiber: Fiber, parentFiber: ?Fiber): void => {
495548
if (__DEBUG__) {
496-
const displayName = getDisplayNameForFiber(fiber) || 'null';
549+
const displayName =
550+
fiber.tag + ':' + (getDisplayNameForFiber(fiber) || 'null');
497551
const id = getFiberID(fiber);
498-
const parentDisplayName =
499-
(parentFiber != null && getDisplayNameForFiber(parentFiber)) || 'null';
552+
const parentDisplayName = parentFiber
553+
? parentFiber.tag +
554+
':' +
555+
(getDisplayNameForFiber(parentFiber) || 'null')
556+
: '';
500557
const parentID = parentFiber ? getFiberID(parentFiber) : '';
501558
// NOTE: calling getFiberID or getPrimaryFiber is unsafe here
502559
// because it will put them in the map. For now, we'll omit them.
@@ -1207,6 +1264,7 @@ export function attach(
12071264
return;
12081265
}
12091266
const id = getFiberID(primaryFiber);
1267+
12101268
if (isRoot) {
12111269
// Roots must be removed only after all children (pending and simulated) have been removed.
12121270
// So we track it separately.

packages/react-devtools-shared/src/backend/types.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,20 @@ export type WorkTagMap = {|
3535
ForwardRef: WorkTag,
3636
Fragment: WorkTag,
3737
FunctionComponent: WorkTag,
38+
FundamentalComponent: WorkTag,
3839
HostComponent: WorkTag,
3940
HostPortal: WorkTag,
4041
HostRoot: WorkTag,
4142
HostText: WorkTag,
4243
IncompleteClassComponent: WorkTag,
4344
IndeterminateComponent: WorkTag,
4445
LazyComponent: WorkTag,
46+
LegacyHiddenComponent: WorkTag,
4547
MemoComponent: WorkTag,
4648
Mode: WorkTag,
4749
OffscreenComponent: WorkTag,
4850
Profiler: WorkTag,
51+
ScopeComponent: WorkTag,
4952
SimpleMemoComponent: WorkTag,
5053
SuspenseComponent: WorkTag,
5154
SuspenseListComponent: WorkTag,

packages/react-dom/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-dom",
3-
"version": "17.0.1",
3+
"version": "17.0.2",
44
"description": "React package for working with the DOM.",
55
"main": "index.js",
66
"repository": {
@@ -22,7 +22,7 @@
2222
"scheduler": "^0.20.1"
2323
},
2424
"peerDependencies": {
25-
"react": "17.0.1"
25+
"react": "17.0.2"
2626
},
2727
"files": [
2828
"LICENSE",

packages/react-is/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-is",
3-
"version": "17.0.1",
3+
"version": "17.0.2",
44
"description": "Brand checking of React Elements.",
55
"main": "index.js",
66
"repository": {

packages/react-reconciler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"node": ">=0.10.0"
2727
},
2828
"peerDependencies": {
29-
"react": "^17.0.1"
29+
"react": "^17.0.2"
3030
},
3131
"dependencies": {
3232
"loose-envify": "^1.1.0",

packages/react-test-renderer/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-test-renderer",
3-
"version": "17.0.1",
3+
"version": "17.0.2",
44
"description": "React package for snapshot testing.",
55
"main": "index.js",
66
"repository": {
@@ -20,12 +20,12 @@
2020
"homepage": "https://reactjs.org/",
2121
"dependencies": {
2222
"object-assign": "^4.1.1",
23-
"react-is": "^17.0.1",
23+
"react-is": "^17.0.2",
2424
"react-shallow-renderer": "^16.13.1",
2525
"scheduler": "^0.20.1"
2626
},
2727
"peerDependencies": {
28-
"react": "17.0.1"
28+
"react": "17.0.2"
2929
},
3030
"files": [
3131
"LICENSE",

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"keywords": [
55
"react"
66
],
7-
"version": "17.0.1",
7+
"version": "17.0.2",
88
"homepage": "https://reactjs.org/",
99
"bugs": "https://github.com/facebook/react/issues",
1010
"license": "MIT",

packages/shared/ReactVersion.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@
66
*/
77

88
// TODO: this is special because it gets imported during build.
9-
export default '17.0.1';
9+
//
10+
// TODO: 17.0.2 has not been released to NPM;
11+
// It exists as a placeholder so that DevTools can support work tag changes between releases.
12+
// When we next publish a release (either 17.0.2 or 17.1.0), update the matching TODO in backend/renderer.js
13+
export default '17.0.2';

0 commit comments

Comments
 (0)