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

后端 未结 5 1801
無奈伤痛
無奈伤痛 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:31

    Your initial data state is String., String does not have method .map, you need change your initial state from '' to []

    this.state = {  data: [] };
    

提交回复
热议问题