yyqdbngt opened a new pull request, #2931:
URL: https://github.com/apache/rocketmq-dashboard/pull/2931

   ## Summary
   - `useVisiblePolling` now skips scheduling when `intervalMs` is not finite 
or not positive (a `NaN`/`0`/negative interval would make `setInterval` fire as 
fast as the event loop allows)
   - The poll callback is tracked in a ref and the subscription now depends 
only on `[enabled, intervalMs]`, so callers passing an inline (non-memoized) 
callback no longer reset the interval on every render
   - Adds regression tests: a non-finite/non-positive interval schedules 
nothing, and the polling cadence survives re-renders that replace the callback 
identity
   
   ## Why
   The effect's dependency array included the `poll` callback, so a parent that 
re-renders (e.g. while loading data) with a fresh inline callback cleared and 
re-created the interval on every render — the timer was perpetually reset and 
the tick could never elapse, silently disabling auto-refresh. Separately, 
nothing validated `intervalMs`, so a malformed interval value would turn the 
interval into a millisecond-resolution loop hammering the poll callback.
   
   ## Testing
   - `./node_modules/.bin/vitest run src/hooks/useVisiblePolling.test.tsx` → 6 
passed (2 new; verified both fail with the pre-fix hook)
   - `./node_modules/.bin/tsc --noEmit` → clean
   - `./node_modules/.bin/eslint src/hooks/useVisiblePolling.ts 
src/hooks/useVisiblePolling.test.tsx` → 0 errors, 0 warnings
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to