Uncaught TypeError: this.state.data.map is not a function

后端 未结 5 1797
無奈伤痛
無奈伤痛 2020-12-15 18:06

I am new to React, have seen some of the similar issues, but didn’t find why this happens. I am getting an “Uncaught TypeError: this.state.data.map is not a function”. Here

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 18:44

    First you must split data to an array, then you may use the map function. Instead of

     this.state.data.map
    

    use

    this.state.data.split('').map()
    

提交回复
热议问题