Phase 2: Implement React hooks, context, and routing for Angular to React migration #90
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.
Phase 2: Implement React hooks, context, and routing for Angular to React migration
Summary
This PR implements Phase 2 of the Angular to React migration by creating parallel React infrastructure without modifying the existing Angular application. The React code is isolated in
src/react/and uses a separate Vite build system.Key Changes:
useHackerNewsAPIhook (src/react/hooks/useHackerNewsAPI.ts): Migrated from Angular's RxJS-based HackerNewsAPIService to nativefetchwith async/await. IncludesfetchFeed,fetchItemContent(with concurrent poll fetching via Promise.all), andfetchUsermethods.SettingsContext+useSettingshook (src/react/contexts/SettingsContext.tsx): Migrated from Angular's SettingsService with localStorage persistence for theme, font size, and list spacing. Includes system dark mode detection viamatchMedialistener with proper cleanup.src/react/App.tsx): Configured all 7 routes matching Angular (news, newest, show, ask, jobs, item, user) with lazy loading for item and user pages usingReact.lazy()andSuspense.Dependencies Added:
The React build (
npm run react:build) completes successfully with no TypeScript errors. The dev server (npm run react:dev) starts and serves the app athttp://localhost:3000.Review & Testing Checklist for Human
High Priority - Must Test:
useHackerNewsAPIhook has not been tested with actual API requests. Create a test component that callsfetchFeed,fetchItemContent, andfetchUserto verify the API integration works correctly and error handling is robust.matchMedialistener/news/1and/item/12345were tested. Manually navigate to all routes (/newest/:page,/show/:page,/ask/:page,/jobs/:page,/user/:id) to ensure routing works correctly.Medium Priority - Should Verify:
fetchItemContentmethod usesPromise.allto fetch poll options concurrently. Test with a poll item (if available in the API) to verify it works correctly.Notes
src/react/directorynpm run react:buildto CI checks.Link to Devin run: https://app.devin.ai/sessions/0b996b4ba2d046b29651d5302f56efeb
Requested by: @eashansinha
Screenshots:

