RocketChat / RocketChat/Rocket.Chat
refactor(registration): reduce RegisterForm complexity by extracting hooks and subcomponents
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Problem
packages/web-ui-registration/src/RegisterForm.tsx currently starts with:
/* eslint-disable complexity */
This indicates excessive cyclomatic complexity and mixed concerns in a single component.
The file (~316 lines) currently combines:
- Form validation logic
- API error handling logic
- Settings-based conditional logic
- Large, repetitive JSX blocks
- UI rendering and business logic in one place
This makes the component difficult to read, maintain, and safely modify.
Why this matters
- Disabling the complexity linter hides real technical debt
- The registration flow is a critical user path
- Any future change risks regressions due to tightly coupled logic
- Similar forms (e.g.
LoginForm) already follow a more modular pattern
Proposed Solution (Refactor Only – No Behavior Changes)
This issue proposes a pure refactor with zero functional or UI changes, focused on reducing complexity and improving maintainability.
Planned improvements:
-
Extract form validation logic into a custom hook
- Centralize field validation rules
- Preserve existing react-hook-form behavior
-
Extract registration error handling logic into a dedicated hook
- Centralize API error mapping
- Preserve existing error messages and redirects
-
Reduce JSX duplication by extracting reusable form field components
- Keep accessibility (
aria-*) attributes unchanged - Preserve current layout and styling
- Keep accessibility (
-
Remove
eslint-disable complexityfromRegisterForm.tsx
Scope & Guarantees
- No breaking changes
- No new dependencies
- No UX or behavior changes
- Same validation rules and error messages
- Same accessibility attributes
- Refactor only (logic is moved, not rewritten)
Expected Outcome
RegisterForm.tsxcomplexity reduced and linter rule re-enabled- Improved separation of concerns (validation, error handling, UI)
- Cleaner and more maintainable registration code
- Easier future enhancements with lower regression risk
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 with packages/web-ui-registration/src/RegisterForm.tsx and compare its structure with the existing LoginForm pattern. Trace the validation, API error handling, settings conditionals, and repeated JSX before separating them while preserving react-hook-form behavior, messages, redirects, accessibility attributes, layout, and styling. Done means the complexity suppression is removed and the linter passes without behavior changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100