Skip to content

Commit d4acbe8

Browse files
authored
Fixed possible undefined error in TreeContext reducer (#24501)
1 parent 024a727 commit d4acbe8

File tree

1 file changed

+4
-6
lines changed
  • packages/react-devtools-shared/src/devtools/views/Components

1 file changed

+4
-6
lines changed

packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,11 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
377377
}
378378
break;
379379
case 'SELECT_PREVIOUS_ELEMENT_WITH_ERROR_OR_WARNING_IN_TREE': {
380-
if (store.errorCount === 0 && store.warningCount === 0) {
380+
const elementIndicesWithErrorsOrWarnings = store.getElementsWithErrorsAndWarnings();
381+
if (elementIndicesWithErrorsOrWarnings.length === 0) {
381382
return state;
382383
}
383384

384-
const elementIndicesWithErrorsOrWarnings = store.getElementsWithErrorsAndWarnings();
385-
386385
let flatIndex = 0;
387386
if (selectedElementIndex !== null) {
388387
// Resume from the current position in the list.
@@ -419,12 +418,11 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
419418
break;
420419
}
421420
case 'SELECT_NEXT_ELEMENT_WITH_ERROR_OR_WARNING_IN_TREE': {
422-
if (store.errorCount === 0 && store.warningCount === 0) {
421+
const elementIndicesWithErrorsOrWarnings = store.getElementsWithErrorsAndWarnings();
422+
if (elementIndicesWithErrorsOrWarnings.length === 0) {
423423
return state;
424424
}
425425

426-
const elementIndicesWithErrorsOrWarnings = store.getElementsWithErrorsAndWarnings();
427-
428426
let flatIndex = -1;
429427
if (selectedElementIndex !== null) {
430428
// Resume from the current position in the list.

0 commit comments

Comments
 (0)