feature: Phase 2C — React user profile feature - #717
Open
vibhaseshadri-cognition wants to merge 1 commit into
Open
vibhaseshadri-cognition wants to merge 1 commit into
vibhaseshadri-cognition wants to merge 1 commit into
Conversation
Co-Authored-By: Vibha Seshadri <vibha.seshadri@cognition.ai>
🤖 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:
|
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
Phase 2C of the Angular → React migration: ports
UserComponenttoreact/src/features/user/asUserProfile. Builds on the Phase 1 foundation (PR #713) and stays strictly insidereact/src/features/user/; wiring intoAppRoutesis left for Phase 3.Behaviour mirrors
UserComponent: read:idfrom the route, reset state and callhackerNewsApi.fetchUser(id)on mount / id change,errorMessage = 'Could not load user ' + id + '.'on failure,goBack→navigate(-1). Acancelledflag in the effect cleanup guards against stale responses when the id changes mid-request (the Angular version had no such guard).user.aboutis rendered viadangerouslySetInnerHTML, matching[innerHTML].Angular's
:host >>> pre { white-space: pre-wrap }has no React equivalent, so the component is wrapped in<div class="user">and the rule is emitted as.user pre.Angular → React mapping
src/app/user/user.component.tsreact/src/features/user/User.tsx(UserProfile, also default export),react/src/features/user/index.tssrc/app/user/user.component.htmlreact/src/features/user/User.tsx(JSX)src/app/user/user.component.scssreact/src/features/user/User.scsssrc/app/user/user.component.spec.tsreact/src/features/user/User.test.tsxTests (
User.test.tsx, 10 tests)Loader) while the request is pending, no.profileErrorMessagewithCould not load user a., no Loader / profile.name,.right(123 ★),.age(Created …), mobiletitle-block(Profile: a)aboutrendered as HTML (<b>,<pre>) inside.other-details p.other-detailsabsent whenaboutis''and whenaboutisundefinednavigate(-1):idchanges (/user/a→/user/b), Loader shown in between, new profile renderedfetchUsercalled exactly once with the exact idaarriving after navigating tobis ignoredCoverage for
src/features/user: 100% lines / statements / functions, 92.9% branches. Whole React suite: 10 files, 48 tests passing.npm run format:check,npm run lint(only the pre-existing react-refresh warning),npm run buildall pass.Screenshot
Rendered with
UserProfiletemporarily wired into/user/:idlocally (not committed) and the API response mocked, sincenode-hnapi.herokuapp.com/user/:idcurrently returns 404.Notes
react/package.jsonchanges.npm run test:coverageneeds@vitest/coverage-v8, which is not in the Phase 1 lockfile; it was installed locally with--no-savefor verification only._themes.scss(Phase 3 wiring), so it appears unstyled in the mobile screenshot.Devin-Org: engineering
Link to Devin session: https://app.devin.ai/sessions/dcc94e31ae494da69e215afed906d55d
Open in Devin Desktop: https://app.devin.ai/desktop/session/dcc94e31ae494da69e215afed906d55d?variant=devin
Requested by: @vibhaseshadri-cognition