小编Ugu*_*mur的帖子

ES6数组映射不返回任何内容:ReactJS

我有一个数组,我有一个简单的字符串值.我想映射我的数组,因为我试图找到我的字符串值.

我有这样的代码,但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'));
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6 reactjs

4
推荐指数
1
解决办法
1605
查看次数

标签 统计

ecmascript-6 ×1

javascript ×1

reactjs ×1