feat: Add React root to mount React components alongside Angular#174
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Open
feat: Add React root to mount React components alongside Angular#174devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
- Install react@17, react-dom@17, @types/react@17, @types/react-dom@17 - Add #react-root div to index.html alongside <app-root> - Create react-main.ts bootstrap file with a simple Hello from React component - Import react-main from main.ts to include it in the Angular CLI build Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
Author
🤖 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.
feat: Add React root to mount React components alongside Angular
Summary
Sets up React 17 infrastructure alongside the existing Angular 9 app as Phase 1 of an incremental migration. Both frameworks render side-by-side: Angular continues in
<app-root>while React mounts into a new<div id="react-root">. A simple "Hello from React" component is rendered to verify the setup works.Changes:
react@17,react-dom@17and their@typespackages<div id="react-root"></div>tosrc/index.htmlnext to<app-root>src/react-main.ts— a React bootstrap that mounts a simple component viaReactDOM.render()react-mainfromsrc/main.tsas a side-effect import so it's included in the Angular CLI buildNote: Uses
.tswithReact.createElement()rather than.tsxwith JSX, since Angular CLI's default webpack config doesn't resolve.tsxfiles. This avoids needing a custom webpack builder while still achieving the React mounting goal.Local Testing
Verified locally that both Angular and React render side-by-side. The Angular HN feed loads normally, and "Hello from React" appears below the footer.
Review & Testing Checklist for Human
package-lock.json(vianpm install), but the repo already hasyarn.lock. Confirm whether the project should standardize on one package manager to avoid conflictsimport './react-main'inmain.tsis placed after the Angular bootstrap call, but ES module imports are hoisted to the top at compile time. React targets the static#react-rootDOM element so this should be safe, but verify the execution order is correctexport NODE_OPTIONS=--openssl-legacy-provider && npm start) and confirm both Angular content and "Hello from React" text appear on the page.tsvs.tsxfor future migration: If JSX/TSX support is needed going forward, a custom webpack setup (e.g.@angular-builders/custom-webpack) would need to be added in a follow-upNotes
ng buildcompiles successfully with the React additionsRequested by: @matthewguerra-cog
Link to Devin run