try and fix infinite loop for clips loading#36
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses an infinite loop issue in the episode clips loading mechanism by wrapping the handleClipsLoaded callback with useCallback to prevent unnecessary re-renders.
Changes:
- Memoized the
handleClipsLoadedcallback function usinguseCallbackwith an empty dependency array
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| setClipCounts(counts) | ||
| setClips(allClips) | ||
| } | ||
| }, []) |
There was a problem hiding this comment.
The useCallback has an empty dependency array, but the callback uses setClipCounts and setClips. If these setters are not stable (e.g., not from useState), or if there are any external dependencies that should trigger a new callback reference, the empty array could cause stale closures. Verify that setClipCounts and setClips are stable setter functions from useState or include them in the dependency array if needed.
| }, []) | |
| }, [setClipCounts, setClips]) |
No description provided.