@capaj/react2angular
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

React to Angular: The easiest way to use React components in Angular 1

react2angular Build Status NPM Apache2

The easiest way to embed React components in Angular 1 apps! (opposite of angular2react)

Installation

npm install react2angular --save

Usage

1. Create a React component

import { Component } from 'react'

class MyComponent extends Component {
  render() {
    return <div>
      <p>FooBar: {this.props.fooBar}</p>
      <p>Baz: {this.props.baz}</p>
    </div>
  }
}

2. Expose it to Angular

import { react2angular } from 'react2angular'

angular
  .module('myModule', [])
  .component('myComponent', react2angular(MyComponent, ['fooBar', 'baz']))

Note: If you defined propTypes on your component, they will be used to compute component's bindings, and you can omit the 2nd argument:

...
  .component('myComponent', react2angular(MyComponent))

If propTypes are defined and you passed in a 2nd argument, the argument will override propTypes.

3. Use it in your Angular 1 code

<my-component
  foo-bar="3"
  baz="'baz'"
></my-component>

Tests

npm test

License

Apache2

Readme

Keywords

none

Package Sidebar

Install

npm i @capaj/react2angular

Weekly Downloads

1

Version

1.1.5

License

Apache2

Last publish

Collaborators

  • capaj