Migrate service layer from AngularJS to React #3
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.
Migrate service layer from AngularJS to React
Summary
This PR implements the first phase of service layer migration from AngularJS to React, creating React equivalents of
CommentService
andAuthorService
while maintaining full backward compatibility. React components now use React services via Context API instead of accessing Angular services through the bridge helper.Key Changes:
CommentService
andAuthorService
classes using fetch API (same endpoints:localhost:3004/comments
andlocalhost:3004/authors
)ServiceProvider
component using React 15's legacy Context API to provide services to React componentsCommentList
from functional to class component to consume services from contextreactToAngularComponent
bridge to automatically wrap React components withServiceProvider
render
helper functionArchitecture: React components now get services via Context API, while Angular components continue using Angular services via dependency injection. Both service layers coexist during the migration period.
Review & Testing Checklist for Human
http://localhost:3000
and verify comments display with correct author names ("John Doe", "Eddart Stark")npm run api
) to verify graceful degradationTest Plan:
npm run api
(port 3004)npm start
(port 3000)Notes
childContextTypes
/contextTypes
) since React.createContext was added in v16.3Link to Devin run: https://app.devin.ai/sessions/b1a8776083de4bf19288ddf6bcbeeda8
Requested by: @benc-a11y