You could simplify the way you store the skills as follows:
this.state = {
personSkills: {
Person1: ["Skill1", "Skill2"],
Person2: ["Skill3", "Skill4"]
}
};
Now while rendering:
render() {
return (
<div className="App">
{persons.map((eachP) => (
<ul>
{eachP}
{this.state.personSkills[eachP] && this.state.personSkills[eachP].map((skill) => {
return <li>{skill}</li>;
})}
</ul>
))}
</div>
);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…