RocketChat / RocketChat/Rocket.Chat
Fix react-hooks/exhaustive-deps violations in BlockEditor component
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Problem
The BlockEditor component currently disables the react-hooks/exhaustive-deps ESLint rule at the file level.
This hides multiple issues:
useEffecthooks with missing dependencies- An inline callback passed to a custom hook that is not memoized
- Suppressed lint warnings instead of addressing the root causes
As a result, React cannot reliably track when effects should re-run, and the intent of the hook dependencies is unclear.
Affected File
apps/uikit-playground/src/Components/CodeEditor/BlockEditor.tsx
Issues Identified
-
useEffecthooks missing required dependencies such as:setValuescreens[activeScreen]?.changedByEditorscreens[activeScreen]?.payloadproperties
-
Callback passed to
useFormatCodeMirrorValueis recreated on every render -
File-level
/* eslint-disable react-hooks/exhaustive-deps */masks these issues
Proposed Solution
- Remove the file-level
eslint-disable react-hooks/exhaustive-deps - Add all accessed values to
useEffectdependency arrays using a granular dependency pattern (specific nested properties instead of entire objects) - Wrap the callback passed to
useFormatCodeMirrorValuewithuseCallbackand proper dependencies
This approach:
- Fixes the underlying dependency issues instead of suppressing them
- Avoids unnecessary re-renders by not depending on large objects
- Preserves existing component behavior
- Follows recommended React Hooks best practices
Scope
- Limit changes to BlockEditor.tsx only
- No refactors or behavior changes
- Focus exclusively on fixing exhaustive-deps violations
Testing
No code changes yet.
After implementation:
-
ESLint should report no
react-hooks/exhaustive-depswarnings -
TypeScript checks should pass
-
Manual verification needed in UIKit Playground:
- Screen switching
- Code editing and formatting
- No infinite re-render loops
Additional Notes
This issue addresses a single high-impact file. Similar fixes in other files should be handled incrementally in separate issues/PRs.
I plan to work on this issue and submit a PR if this approach is acceptable.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in apps/uikit-playground/src/Components/CodeEditor/BlockEditor.tsx and inspect the useEffect hooks and useFormatCodeMirrorValue callback identified in the issue. Run ESLint and TypeScript checks, then manually verify screen switching, code editing, formatting, and the absence of infinite re-render loops. Done means the file-level disable is removed and no react-hooks/exhaustive-deps warnings remain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, react, typescript
- Domain
- frontend, tooling
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100