{"id":19888188,"url":"https://github.com/ngeenx/ngx-react","last_synced_at":"2025-03-01T04:41:45.248Z","repository":{"id":229265786,"uuid":"776244063","full_name":"ngeenx/ngx-react","owner":"ngeenx","description":"Use React components in Angular","archived":false,"fork":false,"pushed_at":"2024-03-23T04:56:39.000Z","size":136,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-23T12:17:10.417Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ngeenx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-23T01:25:25.000Z","updated_at":"2024-05-31T21:04:54.810Z","dependencies_parsed_at":null,"dependency_job_id":"e901502e-3002-4cfc-a68a-60d2592d5233","html_url":"https://github.com/ngeenx/ngx-react","commit_stats":null,"previous_names":["ngeenx/ngx-react"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngeenx%2Fngx-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngeenx%2Fngx-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngeenx%2Fngx-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngeenx%2Fngx-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngeenx","download_url":"https://codeload.github.com/ngeenx/ngx-react/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241317595,"owners_count":19943201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T18:06:35.241Z","updated_at":"2025-03-01T04:41:45.228Z","avatar_url":"https://github.com/ngeenx.png","language":"TypeScript","funding_links":[],"categories":["Framework Interoperability"],"sub_categories":["Cross-Framework Integration"],"readme":"# ngx-react\r\n\r\nThis simple Angular library integrates React components into Angular applications with ease. It is based on React [createElement](https://react.dev/reference/react/createElement) function and Angular [directives](https://angular.io/guide/attribute-directives) (as [standalone components](https://angular.io/guide/standalone-component)). See source code [here](./projects/ngx-react/src/lib/directives/react-component.directive.ts).\r\n\r\n\u003e [!WARNING]\r\n\u003e This package is experimental. There may be possible performance problems, memory leaks and similar problems. It is your responsibility to use it.\r\n\r\n## [⚡️ Play on StackBlitz](https://stackblitz.com/~/github.com/ngeenx/ngx-react)\r\n\r\n## 📦 Installation\r\n\r\nPlease install with peer dependencies `react` and `react-dom` using your favorite package manager.\r\n\r\n### Compatible Versions\r\n\r\n| Package Version | Angular Version |\r\n|---------|---------|\r\n| 1.x.x | 17.x.x |\r\n| 2.x.x | 18.x.x |\r\n\r\nPNPM\r\n\r\n```bash\r\npnpm i react react-dom @ngeenx/ngx-react\r\n```\r\n\r\nNPM\r\n\r\n```bash\r\nnpm i react react-dom @ngeenx/ngx-react\r\n```\r\n\r\n\u003e [!NOTE]\r\n\u003e Addionaly, you can install `@types/react` and `@types/react-dom` for TypeScript support.\r\n\r\n## 🚀 Usage\r\n\r\n### 1. Import React Directive\r\n\r\nImport `ReactComponentDirective` in your standalone component or module.\r\n\r\n```typescript\r\nimport { ReactComponentDirective } from '@ngeenx/ngx-react';\r\n\r\n@NgModule({\r\n  imports: [\r\n    ...\r\n    ReactComponentDirective\r\n  ]\r\n})\r\n```\r\n\r\n### 2. Update `tsconfig.json`\r\n\r\nAdd the following to your `tsconfig.json` file to allow importing `.tsx` files in Angular Project.\r\n\r\n\u003c!-- TODO: update jsx to react-jsx --\u003e\r\n```json\r\n{\r\n  \"compilerOptions\": {\r\n    \"jsx\": \"react\",\r\n    ...\r\n  }\r\n}\r\n```\r\n\r\n### 3. Create React Component\r\n\r\nCreate a wrapper component for your React component. We will use this component to pass props to the React component.\r\n\r\n```typescript\r\n// ReactApp.tsx\r\n\r\nimport React, { FC, useState } from 'react';\r\n\r\nconst ReactApp: FC\u003cany\u003e = ({ initialInputValue }: any) =\u003e {\r\n  const [inputValue, setInputValue] = useState(initialInputValue);\r\n\r\n  const handleChange = (event: any) =\u003e {\r\n    setInputValue(event.target.value);\r\n  };\r\n\r\n  return (\r\n    \u003cdiv\u003e\r\n      \u003clabel htmlFor=\"myInput\"\u003eLabel:\u003c/label\u003e\r\n\r\n      \u003cinput\r\n        type=\"text\"\r\n        id=\"myInput\"\r\n        value={inputValue}\r\n        onChange={handleChange}\r\n      /\u003e\r\n\r\n      \u003cp\u003eInput Value: {inputValue}\u003c/p\u003e\r\n    \u003c/div\u003e\r\n  );\r\n};\r\n\r\nexport default ReactApp;\r\n```\r\n\r\n### 4. Import in Angular Component\r\n\r\n```typescript\r\n// app.component.ts\r\n\r\nimport { Component, NgModule } from '@angular/core';\r\nimport ReactApp from './ReactApp';\r\n\r\n@Component({\r\n  selector: \"app-component\",\r\n  template: `\u003cdiv\r\n    [reactComponent]=\"ReactApp\"\r\n    [props]=\"props\"\r\n  \u003e\u003c/div\u003e`,\r\n  standalone: true,\r\n  imports: [ReactComponentDirective],\r\n})\r\nexport class StandaloneComponent {\r\n  public ReactApp: typeof ReactApp = ReactApp;\r\n  public props = {\r\n    initialInputValue: \"Some Value\"\r\n  }\r\n}\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngeenx%2Fngx-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngeenx%2Fngx-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngeenx%2Fngx-react/lists"}