Skip to content

Fix React Hooks ESLint Warnings in Components. #5125

@luckyxhq

Description

@luckyxhq

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:

  1. In components/dashboard/table/Filters.tsx (line 42):
  2. The `useOutsideAlerter hook is missing setOpen in the dependency array
  3. ESLint warning: `React Hook useEffect has a missing dependency: setOpen
  4. In components/campaigns/AnnouncementHero.tsx (line 24):
  5. The useMemo hook has an unnecessary dependency on banners (which is an imported constant)
  6. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions