Skip to content

Commit

Permalink
Fixed invalid DevTools work tags
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Brian Vaughn committed Dec 1, 2020
1 parent 148ffe3 commit acf5447
Show file tree
Hide file tree
Showing 3 changed files with 342 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,341 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`commit tree Lazy should support Lazy components (createRoot): 0: CommitTree 1`] = `
Object {
"nodes": Map {
1 => Object {
"children": Array [
2,
],
"displayName": null,
"hocDisplayNames": null,
"id": 1,
"key": null,
"parentID": 0,
"treeBaseDuration": 0,
"type": 11,
},
2 => Object {
"children": Array [
3,
],
"displayName": "App",
"hocDisplayNames": null,
"id": 2,
"key": null,
"parentID": 1,
"treeBaseDuration": 0,
"type": 5,
},
3 => Object {
"children": Array [],
"displayName": "Suspense",
"hocDisplayNames": null,
"id": 3,
"key": null,
"parentID": 2,
"treeBaseDuration": 0,
"type": 12,
},
},
"rootID": 1,
}
`;

exports[`commit tree Lazy should support Lazy components (createRoot): 1: CommitTree 1`] = `
Object {
"nodes": Map {
1 => Object {
"children": Array [
2,
],
"displayName": null,
"hocDisplayNames": null,
"id": 1,
"key": null,
"parentID": 0,
"treeBaseDuration": 0,
"type": 11,
},
2 => Object {
"children": Array [
3,
],
"displayName": "App",
"hocDisplayNames": null,
"id": 2,
"key": null,
"parentID": 1,
"treeBaseDuration": 0,
"type": 5,
},
3 => Object {
"children": Array [
4,
],
"displayName": "Suspense",
"hocDisplayNames": null,
"id": 3,
"key": null,
"parentID": 2,
"treeBaseDuration": 0,
"type": 12,
},
4 => Object {
"children": Array [],
"displayName": "LazyInnerComponent",
"hocDisplayNames": null,
"id": 4,
"key": null,
"parentID": 3,
"treeBaseDuration": 0,
"type": 5,
},
},
"rootID": 1,
}
`;

exports[`commit tree Lazy should support Lazy components (legacy render): 0: CommitTree 1`] = `
Object {
"nodes": Map {
1 => Object {
"children": Array [
2,
],
"displayName": null,
"hocDisplayNames": null,
"id": 1,
"key": null,
"parentID": 0,
"treeBaseDuration": 0,
"type": 11,
},
2 => Object {
"children": Array [
3,
],
"displayName": "App",
"hocDisplayNames": null,
"id": 2,
"key": null,
"parentID": 1,
"treeBaseDuration": 0,
"type": 5,
},
3 => Object {
"children": Array [],
"displayName": "Suspense",
"hocDisplayNames": null,
"id": 3,
"key": null,
"parentID": 2,
"treeBaseDuration": 0,
"type": 12,
},
},
"rootID": 1,
}
`;

exports[`commit tree Lazy should support Lazy components (legacy render): 1: CommitTree 1`] = `
Object {
"nodes": Map {
1 => Object {
"children": Array [
2,
],
"displayName": null,
"hocDisplayNames": null,
"id": 1,
"key": null,
"parentID": 0,
"treeBaseDuration": 0,
"type": 11,
},
2 => Object {
"children": Array [
3,
],
"displayName": "App",
"hocDisplayNames": null,
"id": 2,
"key": null,
"parentID": 1,
"treeBaseDuration": 0,
"type": 5,
},
3 => Object {
"children": Array [
4,
],
"displayName": "Suspense",
"hocDisplayNames": null,
"id": 3,
"key": null,
"parentID": 2,
"treeBaseDuration": 0,
"type": 12,
},
4 => Object {
"children": Array [],
"displayName": "LazyInnerComponent",
"hocDisplayNames": null,
"id": 4,
"key": null,
"parentID": 3,
"treeBaseDuration": 0,
"type": 5,
},
},
"rootID": 1,
}
`;

exports[`commit tree Lazy should support Lazy components that are unmounted before resolving (createRoot): 0: CommitTree 1`] = `
Object {
"nodes": Map {
1 => Object {
"children": Array [
2,
],
"displayName": null,
"hocDisplayNames": null,
"id": 1,
"key": null,
"parentID": 0,
"treeBaseDuration": 0,
"type": 11,
},
2 => Object {
"children": Array [
3,
],
"displayName": "App",
"hocDisplayNames": null,
"id": 2,
"key": null,
"parentID": 1,
"treeBaseDuration": 0,
"type": 5,
},
3 => Object {
"children": Array [],
"displayName": "Suspense",
"hocDisplayNames": null,
"id": 3,
"key": null,
"parentID": 2,
"treeBaseDuration": 0,
"type": 12,
},
},
"rootID": 1,
}
`;

exports[`commit tree Lazy should support Lazy components that are unmounted before resolving (createRoot): 1: CommitTree 1`] = `
Object {
"nodes": Map {
1 => Object {
"children": Array [
2,
],
"displayName": null,
"hocDisplayNames": null,
"id": 1,
"key": null,
"parentID": 0,
"treeBaseDuration": 0,
"type": 11,
},
2 => Object {
"children": Array [],
"displayName": "App",
"hocDisplayNames": null,
"id": 2,
"key": null,
"parentID": 1,
"treeBaseDuration": 0,
"type": 5,
},
},
"rootID": 1,
}
`;

exports[`commit tree Lazy should support Lazy components that are unmounted before resolving (legacy render): 0: CommitTree 1`] = `
Object {
"nodes": Map {
1 => Object {
"children": Array [
2,
],
"displayName": null,
"hocDisplayNames": null,
"id": 1,
"key": null,
"parentID": 0,
"treeBaseDuration": 0,
"type": 11,
},
2 => Object {
"children": Array [
3,
],
"displayName": "App",
"hocDisplayNames": null,
"id": 2,
"key": null,
"parentID": 1,
"treeBaseDuration": 0,
"type": 5,
},
3 => Object {
"children": Array [],
"displayName": "Suspense",
"hocDisplayNames": null,
"id": 3,
"key": null,
"parentID": 2,
"treeBaseDuration": 0,
"type": 12,
},
},
"rootID": 1,
}
`;

exports[`commit tree Lazy should support Lazy components that are unmounted before resolving (legacy render): 1: CommitTree 1`] = `
Object {
"nodes": Map {
1 => Object {
"children": Array [
2,
],
"displayName": null,
"hocDisplayNames": null,
"id": 1,
"key": null,
"parentID": 0,
"treeBaseDuration": 0,
"type": 11,
},
2 => Object {
"children": Array [],
"displayName": "App",
"hocDisplayNames": null,
"id": 2,
"key": null,
"parentID": 1,
"treeBaseDuration": 0,
"type": 5,
},
},
"rootID": 1,
}
`;

exports[`commit tree should be able to rebuild the store tree for each commit: 0: CommitTree 1`] = `
Object {
"nodes": Map {
Expand Down
5 changes: 5 additions & 0 deletions packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export function getInternalReactConstants(
ForwardRef: 11,
Fragment: 7,
FunctionComponent: 0,
FundamentalComponent: 20, // Experimental
HostComponent: 5,
HostPortal: 4,
HostRoot: 3,
Expand Down Expand Up @@ -238,6 +239,7 @@ export function getInternalReactConstants(
ForwardRef: 11,
Fragment: 7,
FunctionComponent: 0,
FundamentalComponent: -1, // Experimental
HostComponent: 5,
HostPortal: 4,
HostRoot: 3,
Expand Down Expand Up @@ -267,6 +269,7 @@ export function getInternalReactConstants(
ForwardRef: 13,
Fragment: 9,
FunctionComponent: 0,
FundamentalComponent: -1, // Experimental
HostComponent: 7,
HostPortal: 6,
HostRoot: 5,
Expand Down Expand Up @@ -296,6 +299,7 @@ export function getInternalReactConstants(
ForwardRef: 14,
Fragment: 10,
FunctionComponent: 1,
FundamentalComponent: -1, // Experimental
HostComponent: 5,
HostPortal: 4,
HostRoot: 3,
Expand Down Expand Up @@ -335,6 +339,7 @@ export function getInternalReactConstants(
FunctionComponent,
IndeterminateComponent,
ForwardRef,
FundamentalComponent,
HostRoot,
HostComponent,
HostPortal,
Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-shared/src/backend/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type WorkTagMap = {|
ForwardRef: WorkTag,
Fragment: WorkTag,
FunctionComponent: WorkTag,
FundamentalComponent: WorkTag,
HostComponent: WorkTag,
HostPortal: WorkTag,
HostRoot: WorkTag,
Expand Down

0 comments on commit acf5447

Please sign in to comment.