Description
There is a potential stale closure bug in the NotificationBell component. The ESLint react-hooks/exhaustive-deps rule is currently flagging a missing dependency in the useCallback hook around line 96.
Because refetch is used inside the useCallback but excluded from the dependency array, the callback might hold onto a stale reference of the refetch function. If the component's state or props change, the cached function might fail to fetch the latest notifications correctly, leading to silent failures or outdated data.
File Location
src/components/NotificationBell.tsx (Line 96)
Steps to Reproduce
- Run
npm run lint in the project root.
- Observe the following warning in the console:
Warning: React Hook useCallback has a missing dependency: 'refetch'. Either include it or remove the dependency array. react-hooks/exhaustive-deps
Expected Behavior
The useCallback hook should include all external variables and functions it references to prevent stale closures, ensuring that the notification fetching mechanism always executes with the most up-to-date scope.
Proposed Solution
- Add
refetch to the useCallback dependency array.
- (Alternatively) If
refetch triggers infinite loops when added, wrap the original refetch definition in a useCallback or use useRef to stabilize its reference.
Impact
This is a small but critical bug that can cause the UI to stop receiving or updating real-time notifications for the user.
I would like to work on this issue under GSSoC '26. Please assign it to me!
Description
There is a potential stale closure bug in the
NotificationBellcomponent. The ESLintreact-hooks/exhaustive-depsrule is currently flagging a missing dependency in theuseCallbackhook around line 96.Because
refetchis used inside theuseCallbackbut excluded from the dependency array, the callback might hold onto a stale reference of therefetchfunction. If the component's state or props change, the cached function might fail to fetch the latest notifications correctly, leading to silent failures or outdated data.File Location
src/components/NotificationBell.tsx(Line 96)Steps to Reproduce
npm run lintin the project root.Warning: React Hook useCallback has a missing dependency: 'refetch'. Either include it or remove the dependency array. react-hooks/exhaustive-depsExpected Behavior
The
useCallbackhook should include all external variables and functions it references to prevent stale closures, ensuring that the notification fetching mechanism always executes with the most up-to-date scope.Proposed Solution
refetchto theuseCallbackdependency array.refetchtriggers infinite loops when added, wrap the originalrefetchdefinition in auseCallbackor useuseRefto stabilize its reference.Impact
This is a small but critical bug that can cause the UI to stop receiving or updating real-time notifications for the user.
I would like to work on this issue under GSSoC '26. Please assign it to me!