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

92
Views
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
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!