Dev: Fix useExhaustiveDependencies — Percentile Calculator#5533
Dev: Fix useExhaustiveDependencies — Percentile Calculator#5533conbrad wants to merge 5 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Could you try playing with percentile calc in dev? There's more significant issues now. Changing years and calculating doesn't do anything
There was a problem hiding this comment.
Oh yeah that's broken, at least we can test this in isolation, this app is a bit tricky.
|



biome-ignore lint/correctness/useExhaustiveDependenciessuppressions fromPercentileCalculatorPageandPercentileStationResultTablecodesFromQueryandyearRangeare stabilized withuseMemoso they can be proper effect deps without causing spurious re-rendersPercentileStationResultTable's snackbar effect adds timeRange as a missing dep — the checkyears.length < timeRangecorrectly re-evaluates when either changesCloses #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