-
Notifications
You must be signed in to change notification settings - Fork 961
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
.
Number.isFinite(hoveredLayerIndex); | |
hoveredLayerIndex !== null; |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
There was a problem hiding this comment.
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).
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
pnpx prettier@2 --write .
andpoetry run format
in the top level directory to format my changes.