我有一个数组,我有一个简单的字符串值。我想映射我的数组,因为我试图找到我的字符串值。
我有这样的代码,但 map 函数不返回任何内容:/
class Application extends React.Component {
constructor(){
super();
this.state = {
questionAnswer: 'is that possible',
question: ['is', 'possible', 'that']
}
}
renderKeywords() {
this.state.question.map((item, key) => {
return (
<span>{item}</span>
);
});
}
render() {
return (
<div>
<div>blabla</div>
{this.renderKeywords()}
</div>
);
}
}
React.render(<Application />, document.getElementById('app'));