Skip to content

Commit

Permalink
devtools: Display root type for root updates in "what caused this upd…
Browse files Browse the repository at this point in the history
…ate?" (facebook#22599)
  • Loading branch information
eps1lon authored and zhengjitf committed Apr 15, 2022
1 parent ca62865 commit 01d25d2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Object {
"timestamp": 16,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -91,7 +91,7 @@ Object {
"timestamp": 15,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -127,7 +127,7 @@ Object {
"timestamp": 18,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -190,7 +190,7 @@ Object {
"timestamp": 12,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -258,7 +258,7 @@ Object {
"timestamp": 25,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -307,7 +307,7 @@ Object {
"timestamp": 35,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -346,7 +346,7 @@ Object {
"timestamp": 45,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -455,7 +455,7 @@ Object {
"timestamp": 12,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -562,7 +562,7 @@ Object {
"timestamp": 25,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -632,7 +632,7 @@ Object {
"timestamp": 35,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -683,7 +683,7 @@ Object {
"timestamp": 45,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -954,7 +954,7 @@ Object {
"timestamp": 11,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -1042,7 +1042,7 @@ Object {
"timestamp": 22,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -1149,7 +1149,7 @@ Object {
"timestamp": 35,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -1359,7 +1359,7 @@ Object {
"timestamp": 13,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -1405,7 +1405,7 @@ Object {
"timestamp": 34,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -1441,7 +1441,7 @@ Object {
"timestamp": 44,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -1624,7 +1624,7 @@ Object {
"timestamp": 24,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 13,
"key": null,
Expand Down Expand Up @@ -1714,7 +1714,7 @@ Object {
"timestamp": 34,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 7,
"key": null,
Expand Down Expand Up @@ -1892,7 +1892,7 @@ Object {
"timestamp": 13,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -1962,7 +1962,7 @@ Object {
"timestamp": 34,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -2013,7 +2013,7 @@ Object {
"timestamp": 44,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -2256,7 +2256,7 @@ Object {
"timestamp": 24,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 13,
"key": null,
Expand Down Expand Up @@ -2343,7 +2343,7 @@ Object {
"timestamp": 34,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 7,
"key": null,
Expand Down Expand Up @@ -2464,7 +2464,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -2541,7 +2541,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -2584,7 +2584,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -2699,7 +2699,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -2740,7 +2740,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -2811,7 +2811,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -2878,7 +2878,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -3029,7 +3029,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -3094,7 +3094,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -3271,7 +3271,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -3441,7 +3441,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -3523,7 +3523,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -3604,7 +3604,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -3739,7 +3739,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -4011,7 +4011,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -4147,7 +4147,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down Expand Up @@ -4282,7 +4282,7 @@ Object {
"timestamp": 0,
"updaters": Array [
Object {
"displayName": "Anonymous",
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
Expand Down
4 changes: 4 additions & 0 deletions packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ export function getInternalReactConstants(
getDisplayName(resolvedType, 'Anonymous')
);
case HostRoot:
const fiberRoot = fiber.stateNode;
if (fiberRoot != null && fiberRoot._debugRootType !== null) {
return fiberRoot._debugRootType;
}
return null;
case HostComponent:
return type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as React from 'react';
import {useContext} from 'react';
import {ProfilerContext} from './ProfilerContext';
import styles from './Updaters.css';
import {ElementTypeRoot} from '../../../types';

export type Props = {|
commitTree: CommitTree,
Expand All @@ -26,8 +27,9 @@ export default function Updaters({commitTree, updaters}: Props) {
const children =
updaters.length > 0 ? (
updaters.map<React$Node>((serializedElement: SerializedElement) => {
const {displayName, id, key} = serializedElement;
const isVisibleInTree = commitTree.nodes.has(id);
const {displayName, id, key, type} = serializedElement;
const isVisibleInTree =
commitTree.nodes.has(id) && type !== ElementTypeRoot;
if (isVisibleInTree) {
return (
<button
Expand Down

0 comments on commit 01d25d2

Please sign in to comment.