Skip to content

Phase 1: Angular to React Migration - Setup and Foundation#159

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1770211259-react-migration-phase1
Open

Phase 1: Angular to React Migration - Setup and Foundation#159
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1770211259-react-migration-phase1

Conversation

@devin-ai-integration
Copy link

Phase 1: Angular to React Migration - Setup and Foundation

Summary

This PR establishes the React foundation for migrating the Angular 9 Hacker News PWA to React. A new react-app/ directory contains a complete React + TypeScript project with Vite, implementing the core services and routing structure from the original Angular application.

Key changes include:

  • React project initialized with Vite and TypeScript (strict mode enabled)
  • React Router configured with all routes matching the Angular app structure, including lazy loading for /item/:id and /user/:id routes
  • HackerNewsAPIService ported to a fetch-based service with React Query hooks (useFeed, useItem, useUser)
  • SettingsService ported to React Context API with localStorage persistence and system color scheme detection
  • TypeScript interfaces for all data models (Story, User, Comment, PollResult, Settings)

This is Phase 1 only - no UI styling or component migration is included.

Review & Testing Checklist for Human

  • Verify API endpoint: The code uses https://node-hnapi.herokuapp.com - confirm this API is still operational (Heroku free tier was deprecated)
  • Security review: UserProfile.tsx uses dangerouslySetInnerHTML for user.about field - assess XSS risk from API responses
  • Test the app locally: Run cd react-app && npm install && npm run dev and verify routes work:
    • Navigate to /news/1, /newest/1, /show/1, /ask/1, /jobs/1
    • Click through to an item detail page (/item/:id)
    • Visit a user profile (/user/:id)
  • Verify lazy loading: Check browser network tab to confirm ItemDetails and UserProfile chunks load on-demand
  • Test settings persistence: Open browser DevTools, modify settings via context, refresh page, and verify localStorage values persist

Notes

  • The poll handling logic in fetchItemContent assumes sequential poll IDs (matching Angular implementation) - this may need validation against actual poll items
  • No package-lock.json was committed - recommend running npm install to generate one for reproducible builds
  • Build passes: npm run build and npm run lint both succeed

Link to Devin run: https://app.devin.ai/sessions/c5d7b7af4e534d9297f47b69695b2786
Requested by: piyush@cognition.ai

- Set up React + TypeScript project using Vite for fast development
- Configure React Router with all routes from Angular app:
  - Feed routes: /news/:page, /newest/:page, /show/:page, /ask/:page, /jobs/:page
  - Item details: /item/:id (lazy loaded)
  - User profile: /user/:id (lazy loaded)
  - Default redirect from / to /news/1
- Port HackerNewsAPIService to React:
  - Created services/hackerNewsApi.ts with fetch-based API calls
  - Created hooks/useHackerNews.ts with React Query hooks
  - Supports fetchFeed, fetchItemContent, fetchPollContent, fetchUser
- Port SettingsService to React Context API:
  - Created context/SettingsContext.tsx with full settings management
  - Supports theme switching (default, night, amoled)
  - localStorage persistence for all settings
  - System preferred color scheme detection
- Add TypeScript type definitions for all models:
  - Story, User, Comment, PollResult, FeedType, Settings

Co-Authored-By: piyush@cognition.ai <piyush@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.

0 participants