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

254
Vistas
How to return a tag from a method in react js?

I want to return a tag from a method so that once I call the method the tags are returned and these tags are used to call a component.

const Populate =() =>
{
  let tags = [];
  analysisinfo.forEach((_item,index) =>
  {
   if(analysisinfo[index].id!== defaultid)
    tags.push(<AU props={analysisinfo[index]} instance ={index}/>);
    console.log({tags});
   }
 return tags;

let me explain in-detail the analysisinfo is an useState array which contains the below values. These values are being passed into this method.

0:
cpu: true
hdd: true
id: "00000000000000000000000000000000"
ram: true 

And pushes these values into tags[]. I want them pushed into array in the form of a <>, so that when I return it calls the <AU..../> tag component which takes the above values as props.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use a combination of filter and map:

const Populate = () => (
    <>
        { 
            analysisinfo
                .filter(i => i.id !== defaultid)
                .map((i, idx) => (
                    <AU props={i} instance={idx} />
                ))
         }
    </>
);
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