Fix robot page exception on TypeError: Cannot read properties of undefined (reading 'cohort') (#2540)

* fix robot page exception on TypeError: Cannot read properties of undefined (reading 'cohort') in .filter

* Update ChartConfigurationFlyout.tsx

* Update ModelAssessmentDashboard.tsx
This commit is contained in:
tongy-msft 2024-05-20 23:47:51 -07:00 коммит произвёл GitHub
Родитель 6898acd095
Коммит 1570b17bb8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -68,9 +68,9 @@ export class ChartConfigurationFlyout extends React.Component<
// maximum which indicates that new cohorts were created.
newCohorts = this.props.datasetCohorts
.filter(
(errorCohort) => errorCohort.cohort.getCohortID() > prevMaxCohortID
(errorCohort) => errorCohort?.cohort?.getCohortID() > prevMaxCohortID
)
.map((errorCohort) => errorCohort.cohort.getCohortID());
.map((errorCohort) => errorCohort?.cohort?.getCohortID());
}
// reset feature-based cohort selection if the underlying feature-based cohorts changed

Просмотреть файл

@ -83,12 +83,12 @@ export class ModelOverviewChartPivot extends React.Component<
// only keep selected stats and cohorts based on cohort ID
labeledStatistics = this.props.labeledStatistics.filter((_, i) =>
this.props.selectedChartCohorts.includes(
chartCohorts[i].cohort.getCohortID()
chartCohorts[i]?.cohort.getCohortID()
)
);
chartCohorts = chartCohorts.filter((errorCohort) =>
this.props.selectedChartCohorts.includes(
errorCohort.cohort.getCohortID()
errorCohort?.cohort.getCohortID()
)
);
} else {

Просмотреть файл

@ -369,7 +369,7 @@ export class ModelAssessmentDashboard extends CohortBasedComponent<
return;
}
const newCohorts = [...this.state.cohorts].filter(
(t) => t.cohort.name !== cohort.cohort.name
(t) => t?.cohort?.name !== cohort?.cohort?.name
);
this.setState({
cohorts: newCohorts