Skip to content

Commit

Permalink
Enable exhaustive-deps; correct any lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
clintandrewhall committed Jun 5, 2020
1 parent e3d88a4 commit 449a767
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 449a767

Please sign in to comment.