Skip to content

Commit

Permalink
ensure hooks run before return to avoid react error
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Jul 28, 2020
1 parent eeb75e0 commit a1b739f
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ export const OutlierExploration: FC<ExplorationProps> = React.memo(({ jobId }) =

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

/* eslint-disable-next-line react-hooks/rules-of-hooks */
const colorRange = useColorRange(
COLOR_RANGE.BLUE,
COLOR_RANGE_SCALE.INFLUENCER,
jobConfig !== undefined ? getFeatureCount(jobConfig.dest.results_field, tableItems) : 1
);

// if it's a searchBar syntax error leave the table visible so they can try again
if (status === INDEX_STATUS.ERROR && !errorMessage.includes('failed to create query')) {
return (
Expand All @@ -74,13 +81,6 @@ export const OutlierExploration: FC<ExplorationProps> = React.memo(({ jobId }) =
);
}

/* eslint-disable-next-line react-hooks/rules-of-hooks */
const colorRange = useColorRange(
COLOR_RANGE.BLUE,
COLOR_RANGE_SCALE.INFLUENCER,
jobConfig !== undefined ? getFeatureCount(jobConfig.dest.results_field, tableItems) : 1
);

return (
<EuiPanel data-test-subj="mlDFAnalyticsOutlierExplorationTablePanel">
{jobConfig !== undefined && needsDestIndexPattern && (
Expand Down

0 comments on commit a1b739f

Please sign in to comment.