Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Remove useEffect in GraphHoverLine.tsx and lift logic #7604

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

VIKTORVAV99
Copy link
Member

@VIKTORVAV99 VIKTORVAV99 commented Dec 22, 2024

Issue

We had a any type and used useEffect hooks.

Description

What started as a quick type fix quickly spiraled into a whole refractor of this part of the code. This enabled me to keep all the existing functionality, make it typesafe, remove the useEffect hook (making it more stable) and simplify the logic a bit.

Overall it's also a tiny bit smaller.

Double check

  • I have run pnpx prettier@2 --write . and poetry run format in the top level directory to format my changes.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 10 changed files in this pull request and generated 1 comment.

Files not reviewed (5)
  • web/src/features/charts/graphUtils.ts: Evaluated as low risk
  • web/src/features/charts/tooltips/AreaGraphTooltip.tsx: Evaluated as low risk
  • web/src/features/charts/CarbonChart.tsx: Evaluated as low risk
  • web/src/features/charts/EmissionChart.tsx: Evaluated as low risk
  • web/src/features/charts/OriginChart.tsx: Evaluated as low risk

markerShowVerticalLine &&
Number.isFinite(markerY) &&
id === hoveredChart &&
Number.isFinite(hoveredLayerIndex);
Copy link
Preview

Copilot AI Dec 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition Number.isFinite(hoveredLayerIndex) is not valid for checking the layer index. It should be hoveredLayerIndex !== null.

Suggested change
Number.isFinite(hoveredLayerIndex);
hoveredLayerIndex !== null;

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why they insist on this when Number.isFinite return false for everything that is not a float or int (an actual number).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant