I'm working on a function that gets an array of objects from an API, in those objects their is an array of tags, I want to return all the tags of those objects to populate a select field in my mark up. This is what I got so far and it's starting to get a bit confusing with all the maps I'm doing, its also returning the values but its returning them the same length of the original array of objects and get rid of any duplicates. What I'm I doing wrong or is their a better way to do this, and I'm using lodash?
renderOptions(){
let dataRef = this.props.designs.items,
tagArray = [],
newArr = []
return(_.map(dataRef, (design) => {
let tags = design.tags,
finalArr
return(_.map(tags, (tag) =>{
tagArray.push(tag)
newArr = [ ...new Set(tagArray) ]
return(_.map(newArr, (item) => {
console.log(item)
return( <li><h1>{item}</h1></li> )
}))
})
)
}))
}