Skip to content

Conversation

@devin-ai-integration
Copy link

feat: Implement Phases 1-4 of Angular to React 18 Migration

Summary

This PR adds a new React 18 application (angular-hn-react/) that mirrors the functionality of the existing Angular Hacker News PWA. The migration covers the first four phases: project setup, core infrastructure, component migration, and routing.

Phase 1 - Project Setup: Created React project with TypeScript using create-react-app, installed react-router-dom and @tanstack/react-query, configured folder structure and Prettier settings.

Phase 2 - Core Infrastructure: Created TypeScript type definitions for Story, Comment, User, and Settings. Implemented useHackerNewsAPI hook for data fetching from the node-hnapi.herokuapp.com API. Implemented useSettings hook with React Context for theme/font/spacing management with localStorage persistence.

Phase 3 - Component Migration: Migrated all 9 Angular components to React functional components:

  • Layout: Header, Footer, Settings
  • Feeds: Feed, Item
  • Item Details: ItemDetails, Comment (recursive)
  • User: User

Phase 4 - Routing: Configured React Router v6 with lazy loading for ItemDetails and User components. Routes match the Angular app structure (news, newest, show, ask, jobs feeds + item/user detail pages).

Review & Testing Checklist for Human

  • Verify API integration works - The app fetches from https://node-hnapi.herokuapp.com/. Load the app and confirm stories appear on the feed pages
  • Test theme switching - Open Settings, switch between Default/Night/AMOLED Black themes, verify colors change and persist after page reload
  • Test navigation - Click through all nav links (top, new, show, ask, jobs), verify pagination works, click into item details and user profiles
  • Verify settings persistence - Change font size and list spacing, reload the page, confirm settings are retained
  • Check lazy loading - Open Network tab, navigate to an item detail page, verify the chunk loads dynamically

Recommended test plan:

  1. cd angular-hn-react && npm install && npm start
  2. Browse the feed, click on a story to view comments
  3. Click on a username to view their profile
  4. Open settings, change theme to Night, adjust font size
  5. Refresh the page and verify settings persisted

Notes

  • The React app is in a separate angular-hn-react/ directory alongside the existing Angular code
  • Uses dangerouslySetInnerHTML for rendering comment/user HTML content from the API (same as Angular app)
  • Note: package.json shows React 19.x was installed (latest from create-react-app) rather than exactly React 18

Link to Devin run: https://app.devin.ai/sessions/5ddb8d2903334f31b690d2f3cea45bf3
Requested by: Satwik Bebortha (satwik.bebortha@cognition.ai) / @satwik-cog

Phase 1: Project Setup and Foundation
- Initialize React 18 project with TypeScript using create-react-app
- Install core dependencies (react-router-dom, @tanstack/react-query)
- Configure project structure with components, hooks, services, types, utils folders
- Migrate Prettier configuration from Angular project

Phase 2: Core Infrastructure
- Create type definitions for Story, Comment, User, and Settings
- Implement useHackerNewsAPI hook for data fetching
- Implement useSettings hook with Context API for settings management
- Setup React Query provider with default options

Phase 3: Component Migration
- Create presentational components: Item, Comment
- Create container components: Feed, ItemDetails, User
- Create layout components: Header, Footer, Settings
- Implement theme support (Default, Night, AMOLED Black)
- Add CSS styles for all components

Phase 4: Routing and Navigation
- Setup React Router v6 with lazy loading for ItemDetails and User
- Configure routes matching Angular app structure
- Implement navigation with active link highlighting

Co-Authored-By: Satwik Bebortha <satwik.bebortha@cognition.ai>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant