'stackEl is not iterable (cannot read property undefined)
I really need your help. I have a setSkillsForDropdownFilters method. From the backend comes to me a list of stacks (technologies), there is a drop-down list from which I can select technologies to sort users. The fact is that in addition to stacks, I get extraStacks and I need to sort them together in one menu. I have an application running, but I'm getting an error that looks like this:
stackEl is not iterable (cannot read property undefined)
And no sorting works for me. What am I doing wrong? Thank you very much
private setSkillsForDropdownFilters(skill: string): void {
const skillsFromArray = this.filteredUsers.map(
(user) => (user as any)[skill]
);
if (skill === 'stack') {
const extraStacks = this.filteredUsers.map(
(user) => (user as any)['extraStack']
)
.reduce((stacksArr, stackEl) => {
stacksArr.push(...stackEl)
return stacksArr;
}, [])
.map((stack: any) => stack.title)
skillsFromArray.push(...extraStacks);
}
if (skill === 'softSkills') {
this.filteredSoftSkills = [...new Set(skillsFromArray.sort())];
} else {
(this as any)[
'filtered' + skill[0].toUpperCase() + skill.slice(1) + 's'
] = [...new Set(skillsFromArray.sort())];
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
