Skip to content

Commit

Permalink
fix tree api being called twice on initial load due to uninitialized …
Browse files Browse the repository at this point in the history
…context being used (#1229)
  • Loading branch information
imatiach-msft authored and gaugup committed Feb 27, 2022
1 parent f6204fb commit 68ac41d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
MetricCohortStats,
ModelAssessmentContext,
defaultModelAssessmentContext,
IErrorAnalysisTreeNode
IErrorAnalysisTreeNode,
IModelAssessmentContext
} from "@responsible-ai/core-ui";
import { localization } from "@responsible-ai/localization";
import { Property } from "csstype";
Expand Down Expand Up @@ -80,15 +81,18 @@ export class TreeViewRenderer extends React.PureComponent<
private static saveStateOnUnmount = true;
public context: React.ContextType<typeof ModelAssessmentContext> =
defaultModelAssessmentContext;
public constructor(props: ITreeViewRendererProps) {
public constructor(
props: ITreeViewRendererProps,
context: IModelAssessmentContext
) {
super(props);
if (
this.props.selectedCohort !== this.props.baseCohort &&
TreeViewRenderer.savedState
) {
this.state = TreeViewRenderer.savedState;
} else {
this.state = createInitialTreeViewState(this.context.errorAnalysisData);
this.state = createInitialTreeViewState(context.errorAnalysisData);
}
TreeViewRenderer.saveStateOnUnmount = true;
}
Expand Down

0 comments on commit 68ac41d

Please sign in to comment.