Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda