Skip to content

Commit

Permalink
Enable exhaustive-deps; correct any lint warnings (#68453)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
clintandrewhall and elasticmachine committed Jun 9, 2020
1 parent 7c0f838 commit 91e4fd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ module.exports = {
{
files: ['x-pack/plugins/canvas/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const withUnconnectedElementsLoadedTelemetry = <P extends {}>(
) =>
function ElementsLoadedTelemetry(props: ElementsLoadedTelemetryProps) {
const { telemetryElementCounts, workpad, telemetryResolvedArgs, ...other } = props;
const { error, pending } = telemetryElementCounts;

const [currentWorkpadId, setWorkpadId] = useState<string | undefined>(undefined);
const [hasReported, setHasReported] = useState(false);
Expand All @@ -87,27 +88,20 @@ export const withUnconnectedElementsLoadedTelemetry = <P extends {}>(
0
);

if (
workpadElementCount === 0 ||
(resolvedArgsAreForWorkpad && telemetryElementCounts.pending === 0)
) {
if (workpadElementCount === 0 || (resolvedArgsAreForWorkpad && pending === 0)) {
setHasReported(true);
} else {
setHasReported(false);
}
} else if (
!hasReported &&
telemetryElementCounts.pending === 0 &&
resolvedArgsAreForWorkpad
) {
if (telemetryElementCounts.error > 0) {
} else if (!hasReported && pending === 0 && resolvedArgsAreForWorkpad) {
if (error > 0) {
trackMetric(METRIC_TYPE.LOADED, [WorkpadLoadedMetric, WorkpadLoadedWithErrorsMetric]);
} else {
trackMetric(METRIC_TYPE.LOADED, WorkpadLoadedMetric);
}
setHasReported(true);
}
});
}, [currentWorkpadId, hasReported, error, pending, telemetryResolvedArgs, workpad]);

return <Component {...(other as P)} workpad={workpad} />;
};
Expand Down

0 comments on commit 91e4fd4

Please sign in to comment.