Skip to content

fix: prevent state updates on unmounted component in useStreams - #16

Merged
viccoder-oops merged 1 commit into
mainfrom
fix/usestreams-cleanup
Aug 6, 2026
Merged

fix: prevent state updates on unmounted component in useStreams#16
viccoder-oops merged 1 commit into
mainfrom
fix/usestreams-cleanup

Conversation

@viccoder-oops

Copy link
Copy Markdown
Owner

Summary

  • Adds a mountedRef guard in useStreams to prevent calling setStreams, setError, and setLoading after the component unmounts
  • Marks mountedRef.current = false in the useEffect cleanup alongside clearInterval
  • Eliminates the React warning "Can't perform a React state update on an unmounted component" that occurred when the polling interval fired after navigation away from the dashboard

Changes

  • src/hooks/useStreams.ts: added mountedRef boolean guard around all state setters inside the async fetch callback; cleanup function now sets mountedRef.current = false before clearing the interval

Closes #4

@viccoder-oops
viccoder-oops merged commit c88b586 into main Aug 6, 2026
1 check failed
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.

fix: useStreams polling continues after component unmount causing memory leak

1 participant