Skip to content

Comments

Fix React Hooks ESLint warnings in Filters and AnnouncementHero components#5126

Open
luckyxhq wants to merge 2 commits intoasyncapi:masterfrom
luckyxhq:fix/react-hooks-eslint-warnings
Open

Fix React Hooks ESLint warnings in Filters and AnnouncementHero components#5126
luckyxhq wants to merge 2 commits intoasyncapi:masterfrom
luckyxhq:fix/react-hooks-eslint-warnings

Conversation

@luckyxhq
Copy link

@luckyxhq luckyxhq commented Feb 10, 2026

Description

This PR fixes React Hooks ESLint warnings found in two components that could lead to potential bugs or code quality issues.

Changes Made

1. components/dashboard/table/Filters.tsx

  • Added missing setOpen dependency to the useEffect hook in useOutsideAlerter
  • This ensures the effect has all required dependencies per React Hooks rules

2. components/campaigns/AnnouncementHero.tsx

  • Removed unnecessary banners dependency from useMemo hook
  • banners is an imported constant that never changes, so including it was unnecessary and could cause needless re-computations

Why These Changes Matter

  • Missing dependencies can lead to stale closures where effects use outdated values
  • Unnecessary dependencies cause components to re-compute when they don't need to
  • Following React Hooks rules makes code more maintainable and prevents subtle bugs

Testing

  • Ran npm run lint to verify the warnings are resolved
  • No new ESLint warnings introduced
  • Applied Prettier formatting to maintain code style consistency

Related Issue

Fixes #5125

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Announcement hero component now properly handles scenarios with no visible banners
    • Filters component improved handling of outside-click detection to ensure consistent interaction behavior
  • Style

    • Updated code formatting for improved readability and consistency across component files

- Add missing setOpen dependency to useEffect in Filters.tsx
- Remove unnecessary banners dependency from useMemo in AnnouncementHero.tsx
- Apply prettier formatting to modified files

Fixes asyncapi#5125
@netlify
Copy link

netlify bot commented Feb 10, 2026

Deploy Preview for asyncapi-website failed.

Built without sensitive environment variables

Name Link
🔨 Latest commit 91ea324
🔍 Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/698aeb0737e85300083b06ea

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Feb 10, 2026

We require all PRs to follow Conventional Commits specification.
More details 👇🏼

 No release type found in pull request title "Fix React Hooks ESLint warnings in Filters and AnnouncementHero components". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

The PR addresses React Hooks ESLint warnings by fixing dependency arrays in two components and updating configuration formatting. Changes include removing an unnecessary constant dependency from useMemo, adding a missing state setter dependency to useEffect, introducing an early return guard for empty banner lists, and minor formatting updates.

Changes

Cohort / File(s) Summary
React Hooks Dependency Fixes
components/campaigns/AnnouncementHero.tsx, components/dashboard/table/Filters.tsx
Fixed ESLint hook warnings: removed unnecessary banners constant from useMemo dependency array, added missing setOpen to useEffect dependencies in Filters, added numberOfVisibleBanners to AnnouncementHero effect, and implemented early return guard when no banners are visible. Includes formatting and structural updates to AnnouncementHero component signature.
Configuration
config/3.0.0.json
Added inline comment after root properties declaration and fixed end-of-file newline formatting. No schema structure changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hooks hop true with deps aligned,
Stale closures left behind,
Banners memoized clean and neat,
ESLint warnings now obsolete!
Config formatted, warnings fixed—
React rules and logic mixed! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The config/3.0.0.json changes (inline comment and EOF formatting) are unrelated to the React Hooks ESLint warnings objective and appear to be out of scope. Remove the config/3.0.0.json changes or clarify their necessity; this file is outside the scope of fixing React Hooks ESLint warnings in components.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: fixing React Hooks ESLint warnings in the two modified components (Filters and AnnouncementHero).
Linked Issues check ✅ Passed All coding requirements from issue #5125 are met: setOpen added to Filters.tsx useEffect dependency array [#5125], and banners removed from AnnouncementHero.tsx useMemo dependency array [#5125].
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
components/campaigns/AnnouncementHero.tsx (1)

49-62: ⚠️ Potential issue | 🟡 Minor

Guard against division by zero when numberOfVisibleBanners is 0.

The useEffect on line 49 runs before the early return on line 60. When numberOfVisibleBanners is 0, the interval fires (index + 1) % 0, which produces NaN and silently corrupts activeIndex. Although the early return prevents visible breakage with the current static data, this is fragile.

Either move the early-return guard before all hooks (not possible per Rules of Hooks), or add a guard inside the effect:

Proposed fix
  useEffect(() => {
+   if (numberOfVisibleBanners === 0) return;
    const interval = setInterval(
      () => setActiveIndex((index) => (index + 1) % numberOfVisibleBanners),
      10000,
    );

    return () => {
      clearInterval(interval);
    };
  }, [numberOfVisibleBanners]);
🤖 Fix all issues with AI agents
In `@components/campaigns/AnnouncementHero.tsx`:
- Around line 21-30: The file AnnouncementHero has many formatting violations
(JSX attributes using double quotes, unwanted trailing commas, and
multiline/inline inconsistencies) causing CI failures; to fix, run the project's
formatter (e.g., npx prettier --write components/campaigns/AnnouncementHero.tsx)
and ensure JSX uses single quotes and Prettier/ESLint rules are respected around
the useMemo block that defines visibleBanners, the AnnouncementHero component
props, and other JSX elements; after formatting, re-commit the updated file so
that the code around AnnouncementHero, visibleBanners, banners, and
shouldShowBanner matches the repo style.

In `@config/3.0.0.json`:
- Line 15: The JSON contains an inline comment after the "properties" key which
invalidates the file; remove the comment text beginning with "#" so the line
becomes a valid JSON key ("properties": { ), or relocate the explanatory note to
external documentation (README) instead; search for the "properties" key in the
shown diff to find and fix the offending inline comment.

Comment on lines +21 to +30
export default function AnnouncementHero({
className = '',
small = false,
}: IAnnouncementHeroProps) {
const [activeIndex, setActiveIndex] = useState(0);

const visibleBanners = useMemo(() => banners.filter((banner) => shouldShowBanner(banner.cfpDeadline)), [banners]);
const visibleBanners = useMemo(
() => banners.filter((banner) => shouldShowBanner(banner.cfpDeadline)),
[],
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

CI is failing: formatting does not match project Prettier/ESLint config.

The pipeline reports 20+ errors across this file. Two recurring categories:

  1. Double quotes → single quotes: The project enforces single quotes for JSX attributes (e.g., 'text-white' not "text-white").
  2. Trailing commas & multiline expansion: The Prettier config expects inline formatting and no trailing commas in many of these positions.

Please run npx prettier --write components/campaigns/AnnouncementHero.tsx (or the project's configured formatter) and re-commit to fix all formatting violations in one pass.

Also applies to: 34-36, 40-42, 50-53, 65-66, 73-73, 76-77, 101-101, 119-119

🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[error] 21-21: prettier/prettier: Replace ⏎··className·=·'',⏎··small·=·false,⏎ with ·className·=·'',·small·=·false·


[error] 23-23: prettier/prettier: Unexpected trailing comma. comma-dangle


[error] 27-27: prettier/prettier: Replace ⏎····()·=>·banners.filter((banner)·=>·shouldShowBanner(banner.cfpDeadline)),⏎····[],⏎·· with ()·=>·banners.filter((banner)·=>·shouldShowBanner(banner.cfpDeadline)),·[]


[error] 29-29: prettier/prettier: Unexpected trailing comma. comma-dangle

🤖 Prompt for AI Agents
In `@components/campaigns/AnnouncementHero.tsx` around lines 21 - 30, The file
AnnouncementHero has many formatting violations (JSX attributes using double
quotes, unwanted trailing commas, and multiline/inline inconsistencies) causing
CI failures; to fix, run the project's formatter (e.g., npx prettier --write
components/campaigns/AnnouncementHero.tsx) and ensure JSX uses single quotes and
Prettier/ESLint rules are respected around the useMemo block that defines
visibleBanners, the AnnouncementHero component props, and other JSX elements;
after formatting, re-commit the updated file so that the code around
AnnouncementHero, visibleBanners, banners, and shouldShowBanner matches the repo
style.

}
},
"properties": {
"properties": { #there the properties change i create
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Remove inline comment to keep JSON valid.

# is not valid in JSON and will cause schema parsing to fail. Please remove the inline comment or move the note elsewhere (e.g., README or a separate doc).

🔧 Proposed fix
-    "properties": { `#there` the properties change i create 
+    "properties": {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"properties": { #there the properties change i create
"properties": {
🧰 Tools
🪛 Biome (2.3.13)

[error] 15-15: unexpected character #

(parse)

🤖 Prompt for AI Agents
In `@config/3.0.0.json` at line 15, The JSON contains an inline comment after the
"properties" key which invalidates the file; remove the comment text beginning
with "#" so the line becomes a valid JSON key ("properties": { ), or relocate
the explanatory note to external documentation (README) instead; search for the
"properties" key in the shown diff to find and fix the offending inline comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Be Triaged

Development

Successfully merging this pull request may close these issues.

Fix React Hooks ESLint Warnings in Components.

2 participants