chore(angular-react): Migrate SettingsComponent to React#6
Open
devin-ai-integration[bot] wants to merge 5 commits intomainfrom
Open
chore(angular-react): Migrate SettingsComponent to React#6devin-ai-integration[bot] wants to merge 5 commits intomainfrom
devin-ai-integration[bot] wants to merge 5 commits intomainfrom
Conversation
feat: port logic from Angular to React feat: translate template to JSX feat: wire up inputs, events, and dependencies Migrates SettingsComponent from Angular to React: - Reactive FormGroup → useState controlled inputs - formControlName → value + onChange - (ngSubmit) → onSubmit - Angular signals (errors(), isSubmitting()) → useState - UserService injection → props (getCurrentUser, updateUser, onLogout) - Router.navigate → onNavigateToProfile callback - DestroyRef + takeUntilDestroyed → component unmount (no extra cleanup needed) - ListErrorsComponent → inline ListErrors placeholder (TODO) Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Added initialized ref guard so the form initialization runs exactly once on mount, matching Angular's ngOnInit semantics. Without this, unmemoized getCurrentUser prop would cause the effect to re-run on every parent render, wiping in-progress user edits. Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
1. ListErrors now guards against undefined errors.errors with || {},
matching Angular's errorList.errors || {} pattern.
2. Added mountedRef to prevent onNavigateToProfile from firing after
unmount, matching Angular's takeUntilDestroyed(this.destroyRef).
Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
React 18 StrictMode double-invokes effects (mount → cleanup → mount). Without resetting mountedRef to true in the effect body, the ref stays false after the first cleanup, causing handleSubmit callbacks to bail out silently. Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a React functional component (
SettingsComponent.tsx) as a 1:1 port of the existing AngularSettingsComponent. The Angular component is not removed. This is an additive-only change — no existing files are modified.Migration mapping:
FormGroupwithformControlName→useStatecontrolled inputs withonChange(ngSubmit)→onSubmithandlererrors(),isSubmitting()) →useStateUserService/Router/DestroyRefinjection → props (getCurrentUser,updateUser,onLogout,onNavigateToProfile)ngOnInitform patching →useEffectwithinitializedref guard (runs once on mount)takeUntilDestroyed(this.destroyRef)→mountedRefpattern to cancel in-flight async on unmountListErrorsComponent→ inline stub (markedTODO) with defensive|| {}guard matching Angular originalUpdates since last revision
Five bugs identified by Devin Review have been addressed:
initializedref so thengOnInit-equivalent effect runs exactly once on mount, preventing parent re-renders from resetting form fields (lines 66–88).getCurrentUserremains in the deps array to satisfyexhaustive-deps.mountedRefto guard.then()/.catch()callbacks inhandleSubmit(lines 67, 70–75, 97, 101). PreventsonNavigateToProfilefrom firing after the component has unmounted, matching Angular'stakeUntilDestroyed(this.destroyRef).ListErrorsnow useserrors.errors || {}(line 42) to handle unexpected error shapes without crashing, matching the Angular original'serrorList.errors || {}pattern..prettierrcconfig (arrowParens: "avoid",printWidth: 120,trailingComma: "all") as required by CLAUDE.md.mountedReffix — The mount-tracking effect now explicitly setsmountedRef.current = truein the effect body (line 71). Without this, React 18 StrictMode's mount → cleanup → re-mount cycle leavesmountedRefpermanentlyfalse, causing both.then()and.catch()callbacks inhandleSubmitto silently bail out — no navigation on success, no error display on failure.Review & Testing Checklist for Human
react/react-dominpackage.jsonand no TSX config intsconfig.json. The file will not compile without additional setup. Confirm this is intentional for this migration phase.passwordstate defaults to''and is always included in theupdateUserpayload. Depending on the backend, this could unintentionally clear the user's password. The Angular version only sends password when the form control is dirty — this distinction is lost here.isSubmittingnot reset on success path (lines 91–105): On successful update, the component navigates away but never callssetIsSubmitting(false). If navigation is slow or fails, the form stays permanently disabled.initializedref guard vs. empty deps: The init effect uses a ref guard +[getCurrentUser]deps rather than[]. This works but is unconventional — verify the ref guard correctly prevents re-initialization ifgetCurrentUserreference changes.Suggested test plan: Add
reactandreact-domas dev dependencies, render<SettingsComponent>in a test harness with mock props, and verify: (1) form populates fromgetCurrentUserexactly once, (2) submit sends correct payload including only non-empty password, (3) error state rendersListErrorsincluding with malformed error objects, (4) logout button fires callback, (5) unmounting during an in-flightupdateUserdoes not trigger navigation, (6) form submission works correctly under React 18 StrictMode.Notes
ListErrorscomponent is a placeholder — should be replaced with the actual shared component once migrated.Link to Devin session: https://app.devin.ai/sessions/885a7571c31c498d8aeb31891081a88e
Requested by: @lburgers