[PR #4929] [MERGED] fix: resolve react-hooks ESLint errors #4829

Closed
opened 2026-02-22 18:36:37 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/4929
Author: @angelplusultra
Created: 1/28/2026
Status: Merged
Merged: 1/28/2026
Merged by: @timothycarambat

Base: 4917-enable-essential-rules-and-apply-fixes-in-frontend-eslintHead: 4917-fix-react-hooks-errors


📝 Commits (1)

  • 0a308de fix react-hooks linting errors

📊 Changes

8 files changed (+26 additions, -21 deletions)

View changed files

📝 frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Citation/index.jsx (+2 -1)
📝 frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/HistoricalMessage/Actions/index.jsx (+1 -1)
📝 frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/PromptReply/index.jsx (+1 -0)
📝 frontend/src/components/lib/ModelTable/index.jsx (+17 -17)
📝 frontend/src/components/lib/MonoProviderIcon/index.jsx (+1 -0)
📝 frontend/src/pages/Admin/AgentBuilder/HeaderMenu/index.jsx (+2 -2)
📝 frontend/src/pages/Admin/AgentBuilder/nodes/ApiCallNode/index.jsx (+1 -0)
📝 frontend/src/pages/Admin/AgentBuilder/nodes/FlowInfoNode/index.jsx (+1 -0)

📄 Description

Pull Request Type

  • feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Relevant Issues

Base PR: #4923

What is in this change?

This PR fixes ESLint react-hooks rule violations in the frontend:

Hooks called conditionally (rules of hooks violation):

  • Citation/index.jsx - Moved early return after all hooks are called
  • HistoricalMessage/Actions/index.jsx - Moved early return after useTranslation() hook

Component defined inside component:

  • ModelTable/index.jsx - Extracted Wrapper component out of DeviceTypeTag as DeviceTypeTagWrapper to avoid recreating the component on each render

Unstable key usage:

  • HeaderMenu/index.jsx - Replaced Math.random() fallback key with index-based fallback (flow-${index})

ESLint disable directives for valid patterns:

  • PromptReply/index.jsx - Disabled react-hooks/refs for valid ref usage
  • ApiCallNode/index.jsx - Disabled react-hooks/refs for valid ref usage
  • FlowInfoNode/index.jsx - Disabled react-hooks/refs for forwardRef pattern
  • MonoProviderIcon/index.jsx - Disabled react-hooks/static-components for static icon mapping

Additional Information

These changes are part of the frontend ESLint cleanup effort to enable stricter linting rules.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/4929 **Author:** [@angelplusultra](https://github.com/angelplusultra) **Created:** 1/28/2026 **Status:** ✅ Merged **Merged:** 1/28/2026 **Merged by:** [@timothycarambat](https://github.com/timothycarambat) **Base:** `4917-enable-essential-rules-and-apply-fixes-in-frontend-eslint` ← **Head:** `4917-fix-react-hooks-errors` --- ### 📝 Commits (1) - [`0a308de`](https://github.com/Mintplex-Labs/anything-llm/commit/0a308de1051fb747112d560eac8dd92678b80033) fix react-hooks linting errors ### 📊 Changes **8 files changed** (+26 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Citation/index.jsx` (+2 -1) 📝 `frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/HistoricalMessage/Actions/index.jsx` (+1 -1) 📝 `frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/PromptReply/index.jsx` (+1 -0) 📝 `frontend/src/components/lib/ModelTable/index.jsx` (+17 -17) 📝 `frontend/src/components/lib/MonoProviderIcon/index.jsx` (+1 -0) 📝 `frontend/src/pages/Admin/AgentBuilder/HeaderMenu/index.jsx` (+2 -2) 📝 `frontend/src/pages/Admin/AgentBuilder/nodes/ApiCallNode/index.jsx` (+1 -0) 📝 `frontend/src/pages/Admin/AgentBuilder/nodes/FlowInfoNode/index.jsx` (+1 -0) </details> ### 📄 Description ### Pull Request Type - [ ] ✨ feat - [x] 🐛 fix - [ ] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### Relevant Issues Base PR: #4923 ### What is in this change? This PR fixes ESLint `react-hooks` rule violations in the frontend: **Hooks called conditionally (rules of hooks violation):** - `Citation/index.jsx` - Moved early return after all hooks are called - `HistoricalMessage/Actions/index.jsx` - Moved early return after `useTranslation()` hook **Component defined inside component:** - `ModelTable/index.jsx` - Extracted `Wrapper` component out of `DeviceTypeTag` as `DeviceTypeTagWrapper` to avoid recreating the component on each render **Unstable key usage:** - `HeaderMenu/index.jsx` - Replaced `Math.random()` fallback key with index-based fallback (`flow-${index}`) **ESLint disable directives for valid patterns:** - `PromptReply/index.jsx` - Disabled `react-hooks/refs` for valid ref usage - `ApiCallNode/index.jsx` - Disabled `react-hooks/refs` for valid ref usage - `FlowInfoNode/index.jsx` - Disabled `react-hooks/refs` for forwardRef pattern - `MonoProviderIcon/index.jsx` - Disabled `react-hooks/static-components` for static icon mapping ### Additional Information These changes are part of the frontend ESLint cleanup effort to enable stricter linting rules. ### Developer Validations - [x] I ran `yarn lint` from the root of the repo & committed changes - [ ] Relevant documentation has been updated - [x] I have tested my code functionality - [ ] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:36:37 -05:00
yindo closed this issue 2026-02-22 18:36:37 -05:00
yindo changed title from [PR #4929] fix: resolve react-hooks ESLint errors to [PR #4929] [MERGED] fix: resolve react-hooks ESLint errors 2026-06-05 15:20:35 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4829