Skip to content

Commit

Permalink
Fix robot page exception on TypeError: Cannot read properties of unde…
Browse files Browse the repository at this point in the history
…fined (reading 'cohort') (#2540)

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

* Update ChartConfigurationFlyout.tsx

* Update ModelAssessmentDashboard.tsx
  • Loading branch information
tongyu-microsoft authored May 21, 2024
1 parent 6898acd commit 1570b17
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1570b17

Please sign in to comment.