Skip to content

Commit 7a9fc3c

Browse files
ensure hooks run before return to avoid react error
1 parent 6040321 commit 7a9fc3c

File tree

1 file changed

+7
-7
lines changed
  • x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration

1 file changed

+7
-7
lines changed

x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/outlier_exploration.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ export const OutlierExploration: FC<ExplorationProps> = React.memo(({ jobId }) =
5656

5757
const { columnsWithCharts, errorMessage, status, tableItems } = outlierData;
5858

59+
/* eslint-disable-next-line react-hooks/rules-of-hooks */
60+
const colorRange = useColorRange(
61+
COLOR_RANGE.BLUE,
62+
COLOR_RANGE_SCALE.INFLUENCER,
63+
jobConfig !== undefined ? getFeatureCount(jobConfig.dest.results_field, tableItems) : 1
64+
);
65+
5966
// if it's a searchBar syntax error leave the table visible so they can try again
6067
if (status === INDEX_STATUS.ERROR && !errorMessage.includes('failed to create query')) {
6168
return (
@@ -74,13 +81,6 @@ export const OutlierExploration: FC<ExplorationProps> = React.memo(({ jobId }) =
7481
);
7582
}
7683

77-
/* eslint-disable-next-line react-hooks/rules-of-hooks */
78-
const colorRange = useColorRange(
79-
COLOR_RANGE.BLUE,
80-
COLOR_RANGE_SCALE.INFLUENCER,
81-
jobConfig !== undefined ? getFeatureCount(jobConfig.dest.results_field, tableItems) : 1
82-
);
83-
8484
return (
8585
<EuiPanel data-test-subj="mlDFAnalyticsOutlierExplorationTablePanel">
8686
{jobConfig !== undefined && needsDestIndexPattern && (

0 commit comments

Comments
 (0)