Use React components inside Angular
Перейти к файлу
Ben Grynhaus 13ff801cc7
Allow specifying arbitrary event handlers to any ReactWrapperComponent (#39)
Using the [`geteventlisteners`](https://www.npmjs.com/package/geteventlisteners) package to allow capturing arbitrary event handlers specified as `@Output`s on any React-wrapper component. e.g.:
```html
<fab-icon iconName="Add" (onClick)="handleIconClick($event)" (onMouseOver)="handleIconMouseOver($event)"></fab-icon>
```
```typescript
handleIconClick(ev: MouseEvent) {
  console.log('icon clicked!', ev);  
}

handleIconMouseOver(ev: MouseEvent) {
  console.log('icon moused-over!', ev);  
}
```

Although extending global prototypes (i.e. not-yours) is bad practice, this is what Angular uses to capture events, and this seemed like the only way to get any arbitrary output from the element.
The other option is to handle each specific event, which is a rather long list, and requires further maintenance, when the DOM, React or the component library adds events to listen to.
This is similar in the idea as us passing any arbitrary attribute to the underlying React component.
2018-12-01 20:47:31 +02:00
.circleci gh-pages fix in CircleCI 2018-10-20 11:35:47 +03:00
.vscode [Core] Added stylenames package (bundleded dependency) 2018-10-19 22:17:13 +03:00
apps Allow specifying arbitrary event handlers to any ReactWrapperComponent (#39) 2018-12-01 20:47:31 +02:00
docs Update to fix after github move. 2018-08-10 15:17:01 -07:00
libs Allow specifying arbitrary event handlers to any ReactWrapperComponent (#39) 2018-12-01 20:47:31 +02:00
tools Upgrade all dependencies- Angular 6.1- TypeScript 2.9.2- office-ui-fabric-react 6.43.0 2018-08-02 11:16:43 +03:00
.editorconfig chore: initial commit from @angular/cli 2018-04-03 20:24:44 -07:00
.gitignore Removed ignoring docs in git (used for GitHub pages) 2018-08-02 18:56:19 +03:00
.prettierrc prettier formatting 2018-07-13 16:28:03 +03:00
CHANGELOG.md 0.4.8 (#34) 2018-10-21 14:01:01 +03:00
CODE_OF_CONDUCT.md Update to docs. 2018-08-16 11:23:31 -07:00
CONTRIBUTING.md Update to docs. 2018-08-16 11:23:31 -07:00
LICENSE Update to docs. 2018-08-16 11:23:31 -07:00
README.md Fix issue where contribution link in README linked to the wrong repo 2018-10-02 10:57:05 -07:00
angular.json remove non-maintained projects 2018-08-02 11:16:46 +03:00
nx.json Update to license/copyright on each lib file. Lint fixes. 2018-08-16 12:17:03 -07:00
package-lock.json Allow specifying arbitrary event handlers to any ReactWrapperComponent (#39) 2018-12-01 20:47:31 +02:00
package.json Allow specifying arbitrary event handlers to any ReactWrapperComponent (#39) 2018-12-01 20:47:31 +02:00
tsconfig.json Added `skipLibCheck: true` to root tsconfig.json. 2018-10-16 00:23:30 +03:00
tsconfig.packages.json [Panel] WIP 2018-06-28 19:39:44 +03:00
tslint.json Upgrade all dependencies- Angular 6.1- TypeScript 2.9.2- office-ui-fabric-react 6.43.0 2018-08-02 11:16:43 +03:00

README.md

React support for Angular

npm version

Industry trends, organizational pressures, and other factors can lead to mandates regarding the use of component libraries or migration from one technology to another. In the case of Office UI Fabric, where its use is required, the client must be written in React (there is no Angular component library for the latest version). Rewrite from Angular to React may be cost-prohibitive or ill advised for other reasons.

Use of Angular-React allows consuming any React elements, but specifically Office UI Fabric, within an Angular [2+] application. The library of wrappers for Office UI Fabric simplifies the use of these components with Angular. However, any React code can make use of the custom Angular-React renderer.

@angular-react/fabric | Documentation, quick start, and guides | Demo | Contributing | StackBlitz Template | Office UI Fabric

Typical Use Cases

  • Use React component libraries with Angular
  • Incrementally rewrite an Angular application into React (moving from atomic/leaf nodes upward into full features/pages until the entire app is re-written)

Libraries

  • core: Includes the Renderer and supporting logic to render Angular components with React implementations as React components.
  • fabric: The light-weight Angular component wrappers that expose the Fabric React component api through common Angular components (including both imperative AND declrative syntax in many cases).

Roadmap

Initial work to prove the feasibility of adapting the Angular Renderer to output React managed components has concluded. We have moved beyond the initial simple Fabric components and expanded coverage to much of the available Office UI Fabric component library.

In the coming months we will continue to refine the component implementations as we use the angular-react core and fabric libraries in 2 real-world consumer facing production applications.

Getting started

See our Getting Started Guide if you're building your first project with Angular-React.

If you'd like to contribute, you must follow our contributing guidelines. You can look through the issues (which should be up-to-date on who is working on which features and which pieces are blocked) and make a comment.