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

93
Vistas
Re-factoring map function so that a string is returned instead

I have a React component that consumes the value objects - which gives us access to an array, but currently, using the map function is going to return an array of labels/ assistants as opposed to just one string value. Can anyone help out I would best refactor this code to reflect this change? The current implementation does return the correct values, but I'm just not sure its the right use of map.


const FirstRepeatAttributeLabelAssistant = ({ objects, className }: Props) => {
  if (objects.length === 0) {
    return null;
  }

  let label = objects[0].attributeCollection.questions.map((question) => {
    return question._contributions.label;
  });

  let assistant = objects[0].attributeCollection.questions.map((question) => {
    return question._contributions.assistant;
  });

  return (
    <StyledGroup as={Row}>
      <StyledLabelWrapper>{label}</StyledLabelWrapper>
      <Column size={12} />

      <Column>
        <StyledAssistantWrapper>{assistant}</StyledAssistantWrapper>
      </Column>
    </StyledGroup>
  );
};

This is the array in question:

enter image description here

So, I really just want to assign my values label & assistant to those in this array.

Current output when I console.log(labely);:

enter image description here

about 4 years ago · Juan Pablo Isaza
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