Skip to content

Commit

Permalink
devtools: Display actual ReactDOM API name in root type
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Sep 20, 2021
1 parent ea5c55a commit c14a584
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ describe('InspectedElement', () => {
"a": 1,
"b": "abc",
},
"rootType": "createLegacyRoot()",
"rootType": "render()",
"state": null,
}
`);
Expand Down Expand Up @@ -1585,7 +1585,7 @@ describe('InspectedElement', () => {
"a": 1,
"b": "abc",
},
"rootType": "createLegacyRoot()",
"rootType": "render()",
"state": null,
}
`);
Expand Down Expand Up @@ -1914,7 +1914,7 @@ describe('InspectedElement', () => {
"id": 2,
"owners": null,
"props": Object {},
"rootType": "createLegacyRoot()",
"rootType": "render()",
"state": null,
}
`);
Expand Down Expand Up @@ -1947,7 +1947,7 @@ describe('InspectedElement', () => {
"id": 2,
"owners": null,
"props": Object {},
"rootType": "createLegacyRoot()",
"rootType": "render()",
"state": null,
}
`);
Expand All @@ -1968,9 +1968,7 @@ describe('InspectedElement', () => {
}, false);

const inspectedElement = await inspectElementAtIndex(0);
expect(inspectedElement.rootType).toMatchInlineSnapshot(
`"createLegacyRoot()"`,
);
expect(inspectedElement.rootType).toMatchInlineSnapshot(`"hydrate()"`);
});

it('should display the root type for ReactDOM.render', async () => {
Expand All @@ -1982,9 +1980,7 @@ describe('InspectedElement', () => {
}, false);

const inspectedElement = await inspectElementAtIndex(0);
expect(inspectedElement.rootType).toMatchInlineSnapshot(
`"createLegacyRoot()"`,
);
expect(inspectedElement.rootType).toMatchInlineSnapshot(`"render()"`);
});

it('should display the root type for ReactDOM.hydrateRoot', async () => {
Expand All @@ -1997,7 +1993,7 @@ describe('InspectedElement', () => {
}, false);

const inspectedElement = await inspectElementAtIndex(0);
expect(inspectedElement.rootType).toMatchInlineSnapshot(`"createRoot()"`);
expect(inspectedElement.rootType).toMatchInlineSnapshot(`"hydrateRoot()"`);
});

it('should display the root type for ReactDOM.createRoot', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberRoot.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ function FiberRootNode(containerInfo, tag, hydrate) {
if (__DEV__) {
switch (tag) {
case ConcurrentRoot:
this._debugRootType = 'createRoot()';
this._debugRootType = hydrate ? 'hydrateRoot()' : 'createRoot()';
break;
case LegacyRoot:
this._debugRootType = 'createLegacyRoot()';
this._debugRootType = hydrate ? 'hydrate()' : 'render()';
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberRoot.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ function FiberRootNode(containerInfo, tag, hydrate) {
if (__DEV__) {
switch (tag) {
case ConcurrentRoot:
this._debugRootType = 'createRoot()';
this._debugRootType = hydrate ? 'hydrateRoot()' : 'createRoot()';
break;
case LegacyRoot:
this._debugRootType = 'createLegacyRoot()';
this._debugRootType = hydrate ? 'hydrate()' : 'render()';
break;
}
}
Expand Down

0 comments on commit c14a584

Please sign in to comment.