- • Hooks
+ // This indicates that the component mounted during this commit
+ return (
+
+
+
+ This is the first time the component rendered.
+
);
}
- if (changeDescription.props.length !== 0) {
+
+ const changes = [];
+
+ if (changeDescription.didHooksChange) {
+ changes.push(
+
+ • Hooks changed
+
+ );
+ }
+ if (
+ changeDescription.props !== null &&
+ changeDescription.props.length !== 0
+ ) {
changes.push(
- • Props
+ • Props changed:
{changeDescription.props.map(key => (
{key}
@@ -127,10 +139,13 @@ function WhatChanged({
);
}
- if (changeDescription.state.length !== 0) {
+ if (
+ changeDescription.state !== null &&
+ changeDescription.state.length !== 0
+ ) {
changes.push(
- • State
+ • State changed:
{changeDescription.state.map(key => (
{key}
@@ -141,12 +156,16 @@ function WhatChanged({
}
if (changes.length === 0) {
- changes.push(Nothing
);
+ changes.push(
+
+ The parent component rendered.
+
+ );
}
return (
-
+
{changes}
);
diff --git a/src/devtools/views/Profiler/types.js b/src/devtools/views/Profiler/types.js
index 667ab54ce3..514ff815cf 100644
--- a/src/devtools/views/Profiler/types.js
+++ b/src/devtools/views/Profiler/types.js
@@ -31,11 +31,12 @@ export type SnapshotNode = {|
type: ElementType,
|};
-// TODO (change descriptions) Is it important to handle context?
+// TODO (change descriptions) Should we report changed hooks keys?
export type ChangeDescription = {|
+ context: Array | boolean | null,
didHooksChange: boolean,
- props: Array,
- state: Array,
+ props: Array | null,
+ state: Array | null,
|};
export type CommitDataFrontend = {|
diff --git a/src/devtools/views/Settings/Settings.js b/src/devtools/views/Settings/Settings.js
index b53dee04e2..3e29c19d3b 100644
--- a/src/devtools/views/Settings/Settings.js
+++ b/src/devtools/views/Settings/Settings.js
@@ -174,7 +174,7 @@ function Settings(_: {||}) {
checked={recordChangeDescriptions}
onChange={updateRecordChangeDescriptions}
/>{' '}
- Record which props/state/hooks changed while profiling
+ Record why each component rendered while profiling.
{store.supportsCaptureScreenshots && (