Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
How to add react components to angular project?

I have to add some angular components to angular project and I found this package. I did the following steps:

  1. npm install react2angular react react-dom prop-types --save into the angular project

  2. Add a directory (in the root project) named src and inside it one index.js with the following code:

    import { react2angular } from "react2angular";
    import React from "react";
    
    function Example() {
      return <button type="button">Click me</button>;
    }
    
    angular
      .module("myModule")
      .component("example", react2angular(Example, ["apiUrl", "token"]));
    
  3. after this I moved in the angular code and I added

    <example api-url="123" token="456"/>
    

Nothing happens. No button appears.

This seems to be made based on the official documentation. Did I do something wrong? Keep in mind that I have no experience with angular, this is why I want to work with react.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

1. Create a React component

    import React from 'react';
    const ReactComponent = ({ fooBar, baz}) => (
      <div>
      <span>value: {fooBar} </span>
      <button onClick={baz}>
        Add one
      </button>
      </div>
     );

   export default ReactComponent;

2. Expose it to Angular

    import { react2angular } from 'react2angular'

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

3. Use it in your Angular 1 code

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

https://stackblitz.com/edit/react2angular-multiple-modules-cg9zaw?file=angular-component.js

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!