Useful for injecting React components to AngularJS.
- Install package
npm install --save react-angular-wrapper- Import reactAngularWrapper function
import { reactAngularWrapper } from 'react-angular-wrapper'; - Create component
const ExampleComponent = (props) => (
<div>
<p>{props.name} works!<p>
<p>{props.injected} also!</p>
</div>
);- Render it!
angular
.module('exampleModule')
.constant('injected', 'value')
.component('exampleComponent', reactAngularWrapper(ExampleComponent, ['foo', 'bar'], ['injected']));
Note: Angular bindings (foo,bar) are automatically passed as props to React component. You can use Dependency Injection by giving 3rd argument (injected above).