-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
While running npm run lint, I noticed there are a few React Hooks ESLint warnings in the codebase. These warnings indicate potential issues with dependency arrays in hooks that could lead to stale closures or unnecessary re-renders.
I found two issues that seem straightforward to fix:
- In components/dashboard/table/Filters.tsx (line 42):
- The `useOutsideAlerter hook is missing setOpen in the dependency array
- ESLint warning: `React Hook useEffect has a missing dependency: setOpen
- In
components/campaigns/AnnouncementHero.tsx(line 24): - The
useMemohook has an unnecessary dependency on banners (which is an imported constant) - ESLint warning: `React Hook useMemo has an unnecessary dependency: 'banners'
Why this matters
- Missing dependencies can lead to stale closures where the effect uses outdated values
- Unnecessary dependencies cause components to re-compute/re-render when they don't need to
- Following React Hooks rules makes the code more maintainable and prevents subtle bugs
Proposed Solution
For Filters.tsx:
Add setOpen to the dependency array. Since it's a state setter from useState, it's stable and won't cause extra renders, but including it follows best practices.
For AnnouncementHero.tsx:
Remove banners from the dependency array since it's a module-level constant that never changes.
Steps to Reproduce
npm run lint You'll see the warnings mentioned above.
###Additional Context
I'm happy to submit a PR to fix these if that would be helpful! Let me know if you'd like me to tackle the other warnings as well (there are 3 more in DocsNav.tsx, ToolsCard.tsx, and ToolsDashboard.tsx).
Metadata
Metadata
Assignees
Labels
Type
Projects
Status