Skip to content

Dev: Fix useExhaustiveDependencies — Percentile Calculator#5533

Open
conbrad wants to merge 5 commits into
mainfrom
5525-dev-fix-useexhaustivedependencies-percentile-calculator
Open

Dev: Fix useExhaustiveDependencies — Percentile Calculator#5533
conbrad wants to merge 5 commits into
mainfrom
5525-dev-fix-useexhaustivedependencies-percentile-calculator

Conversation

@conbrad

@conbrad conbrad commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator
  • Removes all biome-ignore lint/correctness/useExhaustiveDependencies suppressions from PercentileCalculatorPage and PercentileStationResultTable
  • codesFromQuery and yearRange are stabilized with useMemo so they can be proper effect deps without causing spurious re-renders
  • Mount-only station fetch now lists dispatch in its dep array (stable ref, same pattern as Dev: Fix useExhaustiveDependencies — Auth (AuthWrapper) #5531)
  • PercentileStationResultTable's snackbar effect adds timeRange as a missing dep — the check years.length < timeRange correctly re-evaluates when either changes

Closes #5525

Test Links:

Landing Page
MoreCast
Percentile Calculator
C-Haines
FireCalc
FireCalc bookmark
Auto Spatial Advisory (ASA)
HFI Calculator
SFMS Insights
Fire Watch
Weather Toolkit

@conbrad conbrad linked an issue Jun 18, 2026 that may be closed by this pull request
4 tasks
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.45%. Comparing base (a4535e4) to head (6bb3652).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5533      +/-   ##
==========================================
+ Coverage   66.32%   66.45%   +0.13%     
==========================================
  Files         380      380              
  Lines       22543    22547       +4     
  Branches     3098     3097       -1     
==========================================
+ Hits        14951    14984      +33     
+ Misses       6439     6407      -32     
- Partials     1153     1156       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@conbrad conbrad requested a review from brettedw June 18, 2026 17:47

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks like it introduces a bit of a behaviour change, where the data will load without hitting Calculate after you adjust the slider. The warning snackbar also just flashes and disappears before being able to read it

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, fixed in: 6bb3652

The root cause was yearRange being listed as a dep of the codesFromQuery effect. When the slider moved, yearRange changed → the effect re-ran → fetchPercentiles fired without a Calculate click.

Fix: store yearRange in a ref that's updated inline during render (yearRangeRef.current = yearRange), then read yearRangeRef.current inside the effect. The effect only depends on
codesFromQuery and dispatch, so it only fires when the URL changes (i.e. Calculate was clicked). The ref always holds the latest value, so the correct year range is still passed to the API.

The snackbar flash was a downstream symptom, the spurious fetch set loading: true, which unmounted the result table and reset its snackbarOpen state. That resolves with the fetch fix.

Added regression tests as well.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you try playing with percentile calc in dev? There's more significant issues now. Changing years and calculating doesn't do anything

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh yeah that's broken, at least we can test this in isolation, this app is a bit tricky.

@sonarqubecloud

Copy link
Copy Markdown

@conbrad conbrad requested a review from brettedw June 18, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dev: Fix useExhaustiveDependencies — Percentile Calculator

2 participants