Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda