Reset selected commit and fiber between profiling sessions
Brian Vaughn committed
Mar 18, 2019 at 13:53 UTC
b64a76e6bdf8db0c9fd26ae038cbf308a4301e57
2 files changed
+11
-1
src/devtools/views/Profiler/ProfilerContext.js
+9
@@ -124,6 +124,15 @@ function ProfilerContextController({ children }: Props) {
124
125
const [selectedFiberID, selectFiber] = useState<number | null>(null);
126
127
+ if (isProfiling) {
128
+ if (selectedFiberID !== null) {
129
+ selectFiber(null);
130
+ }
131
+ if (selectedCommitIndex !== null) {
132
+ setSelectedCommitIndex(null);
133
+ }
134
+ }
135
+
136
const value = useMemo(
137
() => ({
138
hasProfilingData,
src/devtools/views/Profiler/SnapshotSelector.js
+2
-1
@@ -56,7 +56,8 @@ export default function SnapshotSelector(_: Props) {
56
}, [filteredCommitIndices, selectedCommitIndex]);
57
58
// TODO (profiling) This should be managed by the context controller (reducer).
59
- // TODO (profiling) We should also reset the selected index to 0 between profiling sessions.
59
+ // It doesn't currently know about the filtered commits though (since it doesn't suspend).
60
+ // Maybe this component should pass filteredCommitIndices up?
61
if (selectedFilteredCommitIndex === null) {
62
if (numFilteredCommits > 0) {
63
setSelectedCommitIndex(0);